#C2717. Warehouse Inventory Operations
Warehouse Inventory Operations
Warehouse Inventory Operations
You are given a series of test cases representing operations on a warehouse inventory. For each test case, you start with an empty inventory. Each operation is either an "Add" operation which increases the stock of a product or a "Get" operation which queries the current stock of a product.
The operations are provided one per line. There are two types of operations:
- Add p q: Increase the inventory of product p by q units. Formally, if the current stock for product p is S, then it becomes \(S+q\) after the operation.
- Get p: Output the current inventory count of product p. If the product has not been added before, its count is considered as 0.
Each test case is processed independently; that is, the inventory is reset at the beginning of each test case. The result is the concatenation of the outputs from all "Get" operations across all test cases in the order they appear.
inputFormat
The input is read from stdin and has the following format:
- An integer T representing the number of test cases.
- For each test case:
- An integer N representing the number of operations.
- N lines, each containing an operation in one of the two forms: "Add p q" or "Get p".
There are no extra spaces in the input beyond those specified.
outputFormat
Output the result of each "Get" operation in the order they appear, each on a separate line to stdout.
## sample4
5
Add 1 100
Add 2 50
Get 1
Get 2
Get 3
3
Add 5 200
Get 5
Get 1
1
Get 1
3
Add 1 100
Add 1 200
Get 1
100
50
0
200
0
0
300
</p>