Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Your sales department needs software to manage inventory and handle I / O transactions as well as statistics of total I / O values.
Note: Transactions are conducted in order. Shipments are rejected if there is not enough quantity to ship and initially there is no inventory
Input
The first line contains the number of transactions ~N~(~N~ ≤ ~10^{6}~).
~ith~ line in the next ~N~ lines starts with '+' or '-' coresponding to import or export transaction, followed by 3 integers ~Ci~, ~Qi~ and ~Pi~ which are Product's code, quanity and price for each item (~Qi~, ~Pi~ ≤ ~10^{9}~, ~Ci~ contains no more than 9 digits).
Output
At the end of the transactions, for each item that has at least one successful transaction, output the product code, the total value of the import goods, and the total value of goods shipped per line (separated by spaces).
Products are exported in ascending order of product's code.
Sample Input:
6
+ 1 20 20000
- 1 20 30000
+ 2 15 30000
+ 3 20 25000
- 2 25 25000
- 3 5 20000
Sample Output:
1 400000 600000
2 450000 0
3 500000 100000
Bình luận