HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Sorting and sequences > problem:


50735 - Top M Products

Guest
• Review clarifications (1)

Section problems

• 50317 - Student Line Up
• 50311 - Student Line Up
• 50320 - Random Sorted List
• 50736 - Top N Donors - 2
• 50733 - The Highest Average
• 50364 - Student averages
• 50333 - Series of Squares
• 50734 - Product Info (In Srt)
• 50735 - Top M Products
• 50339 - The Largest Rectangle
• 50492 - Contest Scoreboard
• 50737 - Sum of the k-largest numbers
• 50418 - Student averages
• 50875 - Take m-out
• 50748 - Gold Store
• 50766 - Word Puzzle
• 50741 - DNA Distance

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.
Use Classes to solve the problem.

Semicolon Separated 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, where m is the number of items to show on screen.
Then, in the following n lines you will be given semicolon 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 40 chars string. It may contain any ASCII char ending with a semicolon.
  3. Product category: At most 40 chars string. It may contain any ASCII char ending with a semicolon.
  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

Output specification
Show

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

Sample Input
  5 3
  1; Wall Mount Faucet 4"; Faucets; 21.50; 27.52; 8 8 3 17 2;
  2; Sharkbite Fittings 8"; Fittings; 9.11; 10.11; 13 4 21 23 11;
  3; Murano Vessel Lavatory - White; Vessels; 9.71; 12.73; 16 4 25 6 11;
  4; Barbed Fittings 7"; Fittings; 17.80; 19.94; 3 21 7 5 20;
  5; Contemporary Lever Handles; Shower Arms; 1.75; 2.14; 1 9 17 5 25;

Sample Output
  2 72
  3 62
  5 57

Output Explanation :
  Product 2 is the most sold product: 72 pieces of it has been sold. That is followed by the products 3 and 5.


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

www.contester.ru