#C2841. Warehouse Inventory Management
Warehouse Inventory Management
Warehouse Inventory Management
In this problem, you are given a warehouse with (N) different types of items and their initial stock levels. Over (D) days, a series of transactions occur. Each transaction is represented by a triplet ((d, i, q)), where (d) is the day of the transaction, (i) (1-indexed) is the item type, and (q) is the change in the stock quantity (which can be positive or negative). For each day from 1 to (D), update the stocks according to the transactions occurring on that day and then output the total stock count across all items. The final answer for day (d) is given by (S_d = \sum_{j=1}^{N} stock_j) after processing all transactions on that day.
inputFormat
The input is given via standard input (stdin) with the following format:
- The first line contains two integers (N) and (D) -- the number of item types and the number of days, respectively.
- The second line contains (N) space-separated integers representing the initial stock levels for each item type.
- Each of the following lines (if any) contains three integers: (d), (i), and (q), representing a transaction that occurs on day (d) for the (i)-th item with a quantity change of (q). There can be zero or more transaction lines. Read transactions until the end of input.
outputFormat
For each day from 1 to (D), output a single integer on a new line representing the total stock count in the warehouse after processing that day’s transactions. The answers must be printed to standard output (stdout).## sample
3 5
100 200 300
1 1 50
2 2 -30
3 3 100
4 1 -60
5 2 10
650
620
720
660
670
</p>