Submit | All submissions | Best solutions | Back to list |
EISTOCK - Stock Management |
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 <= 106).
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 <= 109, 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
Example
Input:
6
+ 1 20 20000
- 1 20 30000
+ 2 15 30000
+ 3 20 25000
- 2 25 25000
- 3 5 20000
Output:
1 400000 600000
2 450000 0
3 500000 100000
Added by: | Ha Minh Ngoc |
Date: | 2017-08-23 |
Time limit: | 1s-1.200s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: GOSU |