#C1405. Inventory Management System

    ID: 43656 Type: Default 1000ms 256MiB

Inventory Management System

Inventory Management System

You are tasked with implementing an inventory management system that handles unique items identified by a string item_id and associated quantities. The system must process a series of commands to update and query the inventory. The commands are described below:

  • ADD <item_id> <quantity>: Add a specified quantity to the item. If the item does not exist, create it with the given quantity.
  • REMOVE <item_id> <quantity>: Remove a specified quantity from the item. If the remaining quantity is zero or negative, the item is removed from the inventory.
  • QUERY <item_id>: Output the current quantity of the item. If the item does not exist, output "Item not found".

Input/Output Details: The input starts with an integer T representing the number of commands. Each of the following T lines contains one command. For each QUERY command, produce an output on a separate line.

Note: The constraints for the problem are given by:

\( 1 \leq T \leq 100 \), \( 0 \leq \text{quantity} \leq 10^5 \), and the item_id is a string of up to 20 alphanumeric characters.

inputFormat

The first line of input contains an integer T representing the number of commands. Each of the next T lines contains one command in one of the following formats:

  • ADD <item_id> <quantity>
  • REMOVE <item_id> <quantity>
  • QUERY <item_id>

outputFormat

For every QUERY command, output a single line with the current quantity of the specified item. If the item does not exist in the inventory, output "Item not found".

## sample
6
ADD apple 50
ADD banana 30
QUERY apple
REMOVE banana 10
QUERY banana
REMOVE apple 50
50

20 Item not found

</p>