#C9796. Warehouse Inventory System Simulation
Warehouse Inventory System Simulation
Warehouse Inventory System Simulation
You are given a warehouse inventory system simulation task. The system processes a series of operations of two kinds:
- LOAD: Adds a specified quantity of an item to the inventory.
- UNLOAD: Removes a specified quantity of an item from the inventory. If the item does not exist or its quantity is insufficient, the system should report an error by outputting the message "Insufficient items".
The input is provided via standard input: The first line contains an integer \(n\) denoting the number of operations. Then, \(n\) lines follow, each representing an operation in the format COMMAND item quantity
(for example, LOAD apple 100
or UNLOAD apple 50
).
Your task is to simulate the inventory operations. For each unsuccessful UNLOAD
operation (i.e. when an attempt is made to unload more items than available or when the item is not in inventory), output the message "Insufficient items" on a separate line. If there are no such errors, output nothing.
Note: Ensure you read from standard input (stdin) and write your output to standard output (stdout).
inputFormat
The first line of input contains a single integer \(n\) representing the number of operations. The following \(n\) lines each contain one operation in the format:
COMMAND item quantity
Where COMMAND
is either LOAD
or UNLOAD
, item
is a string representing the item name, and quantity
is a positive integer.
outputFormat
For each UNLOAD
operation that fails (either due to the item not existing in the inventory or insufficient quantity), print Insufficient items
on a separate line. If no operations fail, output nothing.
3
LOAD apple 100
LOAD banana 150
LOAD apple 50