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

Турниры > CEN_114 Midterm A > задача:


13. 50735 - Top M Products

CEN_114 Midterm A

Старт: 14.мая.2020 в 00:00:01
Финиш: 31.мая.2020 в 23:55:59
Турнир завершён!
• Турнирная таблица

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

Задачи турнира

• 1. 50467 - Random Numbers
• 10. 51093 - rgb2gray
• 11. 50410 - Zero Padding
• 12. 50470 - Close Pairs - Revised
• 13. 50735 - Top M Products
• 14. 51094 - Passing the course
• 15. 50804 - Marathon
• 3. 50390 - Total Salary Paid
• 4. 50528 - Rock-Scissors-Paper
• 5. 51087 - Are they the same?
• 6. 51092 - Even and Odd
• 7. 50449 - The biggest result
• 8. 51146 - Popular Baby Names

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

Если у вас есть предложения или пожелания по работе 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