#C10939. Warehouse Inventory Management

    ID: 40199 Type: Default 1000ms 256MiB

Warehouse Inventory Management

Warehouse Inventory Management

You are required to implement a warehouse inventory management system. The system processes a series of operations to add, remove, and query items in the warehouse. Each operation is given in the following format:

  • ADD id amount: Add \(amount\) of the item with identifier \(id\) to the inventory.
  • REMOVE id amount: Remove \(amount\) of the item with identifier \(id\) from the inventory, but only if the current inventory for the item is at least \(amount\).
  • QUERY id: Output the current inventory count of the item with identifier \(id\).

The operations are provided as input via standard input. Your program must process them sequentially. Only the results of the QUERY operations should be printed to standard output, each in a new line.

Note: For the REMOVE operation, if the inventory for the item is less than the removal amount, the operation is ignored (i.e. do nothing).

inputFormat

The first line of input contains a single integer \(N\) (the number of operations). Each of the following \(N\) lines contains an operation in one of three formats:

  • ADD id amount
  • REMOVE id amount
  • QUERY id

Here, id and amount are integers.

outputFormat

For each QUERY operation in the input, output a single line with an integer representing the current inventory count for the specified item id.

## sample
6
ADD 1 500
ADD 2 300
QUERY 1
REMOVE 1 100
QUERY 2
QUERY 1
500

300 400

</p>