HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


51024 - Total Stock Price

Guest
• Review clarifications (1)

Volume problems

• 50745 - Bitonic Sequence
• 50789 - Number of Cities
• 50987 - Very Looong Queue
• 50913 - Manhattan Distance
• 50981 - Top popular m-students
• 50729 - Max number in 2D array
• 50743 - Total Scholarships Discount
• 51083 - Grades Histogram
• 51024 - Total Stock Price
• 51008 - Sum of Regional Maxes
• 51014 - Nine Men's Morris game
• Word Puzzle
• 50740 - Service Time - 1
• 50928 - War Of Battleships
• 50930 - Tom and Jerry
• 50925 - Optimizing Elevator Usage
• 50988 - Laplacian Filter

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