HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN303_2016Questions > problem:


PE13. 51024 - Total Stock Price

CEN303_2016Questions

Start: Oct.28.2016 at 05:00:00 PM
Finish: Nov.01.2016 at 05:00:00 AM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• HW083. 50671 - Phalanx
• HW091. 51061 - The Longest Path
• HW101. 50682 - Hotel Durres
• HW102. 51067 - Jumping frog
• HW111. 50506 - The Biggest Island
• HW112. 50698 - Ayran Delivery
• PE11. 51023 - Preparing Keyword I...
• PE12. 50835 - Club Presidency
• PE13. 51024 - Total Stock Price
• PE14. 50998 - CEN112 Homework, ...
• PE21. 51071 - Phalanx-2
• PE22. 51072 - Castle on chessboard
• RE1. 51079 - Key person - 2
• RE2. 51080 - Deepest Point

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.
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



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

www.contester.ru