CEN303_2016Questions |
Старт: 28.окт.2016 в 17:00:00
Финиш: 01.ноя.2016 в 05:00:00
Турнир завершён!
• Турнирная таблица
|
|
Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ibrahim Mesecan.
Total Stock Price
Question:
You are buying and selling items in the stock market.
And, you keep your operations in a database (or in a
file). Write a program
that reads a list of stock market operations, then
prints the total price of m items given.
Input specification:
At the beginning, you will be given two integers:
the number of operations (n) and the number of items (m)
to show the total amount (total price).
Each of the following n lines will have four information
- Item code: a string not more than 12 chars
- Buying or selling: a char (B or S, no other char will be given)
- The number of items to buy: an integer between 1 and 200
- Unit price: a floating point number not greater than 1000
(unit price to buy or sell this item)
where 1 ≤ m ≤ 5,000 and 1 ≤ n ≤ 35,000,
item codes are string
containing only 26 English uppercase or lowercase chars.
Output specification:
Show the total amount of m items.
If the searching item is not in the list,
assume that its total price is 0.
Sample Input
6 3
ASYI B 20 8.90
LSUV B 13 5.60
ANPFF B 4 8.20
ASYI S 13 8.80
ANPFF S 3 0.20
ASYI B 18 7.30
ANPFF
ASYI
LSUV
|
Sample Output
300.00
|
Explanation:
There are 6 operations and the total price of 3 symbols have been asked in the end.
- Symbol LSUV has only one operation, so its total price is 72.8,
- ASYI has been bought twice and sold once,
(20*8.90 + 18 7.30 - 13 8.80) with a total price of 195
- ANPFF has been bought once and sold once,
(4*8.20 - 3*0.20) with a total price of 32.2
Thus, the total price for the m items is 72.8 + 195 + 32.2 = 300
Для отправки решений необходимо выполнить вход.
|