ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Сортировка и последовательности > задача:


50735 - Top M Products

Гость
• Вопросы к жюри (1)

Задачи раздела

• 50756 - Average of the Nth Student
• 50347 - Selling Oranges
• 50758 - National Elections - Revisited
• 50757 - National Elections - 1
• 50755- Top N Donors - 1
• 50290 - Minimax Sum
• 50339 - The Largest Rectangle
• 50753 - Average of the Nth Student
• 50735 - Top M Products
• 50361 - Align Two Lists

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
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