HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


190. 50734 - Product Info (In Srt)

Guest
• Review clarifications (1)

Volume problems

• 151. 50557 - nth Power of m (Long...
• 155. 50334 - What is the class aver...
• 155. 50726 - Pascal Triangle - 1
• 160. 50301 - Fractions to Decimals
• 165. 50360 - National Elections
• 170. 50319 - Toll Plazas
• 180. 50755- Top N Donors - 1
• 185. 50784 - Top Growing Company
• 190. 50734 - Product Info (In Srt)
• 200. 50290 - Minimax Sum
• 210. 50361 - Align Two Lists
• 220. 50754 - Team Standings
• 230. 50286 - Remove Duplicates
• 250. 50448 - Paint Buckets
• 280. 50477 - Character Pyramids

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

Product Info

Mr. Enea, sells building and sanitary materials. After selling the products he processes through his stock book. But, he wants to renew his system and to pass to a computerized system.

Question: Write a program that is going to read the stock information. And, show the most sold top m items.
Note: Use Quick sort to solve the problem.

Input specification
First, you will be given two numbers n and m, where

  • 1 < n ≤ 5000, that shows the number of items in the store
  • 1 < m ≤ 50, that shows the number of top m items to show as the output.
Then, in the following n lines you will be given space separated product information. Every line contains the following information:
  1. Product ID: Every product is given a product ID on its entry. an integer number smaller than 10 million
  2. Product name: At most 20 chars (single word but may contain an under_score sign) string
  3. Product category: At most 20 chars (single word but may contain an under_score sign) string
  4. Entry price: a floating point number
  5. Sell price: a floating point number
  6. Amount sold: The number of items sold on different days. Space separated series of 5 integers
where Product name and Product category fields may contain only English letters and under_score sign.

Output specification
Show

  • the Product ID
  • the Product name and
  • the total amount sold
of the top m items in decreasing order of amount sold.

Sample Input
  5 3
  1 Radiators Supplies 40.00 46.40 12 18 24 7 15
  2 Galvanized Fittings 17.63 21.15 6 1 16 17 1
  3 Flexible Connectors 11.50 13.11 16 12 16 4 22
  4 Larger_Diana Vessels 21.25 25.93 18 25 8 8 19
  5 Carusso Vessels 18.00 24.84 14 18 3 2 25

Sample Output
  4 Larger_Diana 78
  1 Radiators 76
  3 Flexible 70

Output Explanation :
  Product 4 is the most sold product: 78 pieces of it has been sold. That is followed by the products 1 and 3 which have been sold 76 and 70 pieces.


Для отправки решений необходимо выполнить вход.

www.contester.ru