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

Сборники > Data Structures > задача:


50993 - Products in store

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

Задачи сборника

• 50777 - Dwarfs Maze
• 50488 - Connecting Wires
• 50781 - ReversesreveR
• 50780 - Hot Potato - Revisited
• 50681 - Center of a Series
• 50793 - Top M Customers
• Check-Mate
• 51073 - Campus Tours for High Sch...
• 50993 - Products in store
• Post Office Delivery
• 50564 - Kovat e qumeshtit te mamase
• 50593 - Transportimi
• 50598 - Shuma minimale
• 50704 - Te lidhura?
• 50705 - Klubet e studenteve
• 50779 - Rruga me e shkurter ne lab...
• 180. 50776 - Numri i rrugeve te ndry...

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

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

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Products in store

Question: In order to follow the products in store, a whole sale company needs a program. You're first given the ids and amounts of m products from the report for last year. Then, you are given information for m instructions. Find the top k items which have the most number (amount) in the store. Note: Pay attention that the second list may contain new products which was not in the list before.

Input specification: You will be given three integers in the beginning:

  • The number of items existing in the store (n): an integer not greater than 10,000,
  • The number of instructions (m): an integer not greater than 10,000,
  • The number of top products to list (k).
Then, the following n lines contain two information: the product ID and existing amount in the store. Product ID is at most 10 char long alpha-numeric sequence and the amount is a floating point number not greater than 1e6. Then in the following m lines, you will be given m instructions. Each instruction contains three information: a char (E or S), a product ID, and a number where
  • 'E ID N' means N items (of product ID) have entered to the store.
  • 'S ID N' means N items (of product ID) have been sold from the store.

Output specification: Show top k products existing in the store (in descending order). If there are two items with the same amount, show in ascending order according to product IDs.

Sample Input
4 5 2
OMVA61 32
ICKX42 50
WPPZ49 34
EUGO62 52
E OMVA61 51
S EUGO62 13
S ICKX42 34
S OMVA61 56
E GCGW69 56.4
Sample Output
GCGW69
EUGO62

Explanation: There are 4 products in the store. Then, we are given 5 instructions. Here is the list of items and their total amounts after processing m instructions.

Product Code Amount in the store
EUGO62 39
GCGW69 56.4
ICKX42 16
OMVA61 27
WPPZ49 34
Thus, the top two items are GCGW69 and EUGO62.



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

www.contester.ru