#K57522. Inventory Management System
Inventory Management System
Inventory Management System
You are required to implement an inventory management system that processes a series of commands. There are two types of commands: restock and purchase. For a command of the form:
(\texttt{restock; product_id; quantity})
add the given quantity to the inventory of the specified product. For a command of the form:
(\texttt{purchase; product_id; quantity})
attempt to purchase the specified quantity from the product. If there is enough inventory, subtract the quantity and print "SUCCESS"; otherwise, print "FAILURE". Only purchase commands produce output. The commands must be processed in the order they are given.
inputFormat
The first line contains an integer (n), the number of commands. The following (n) lines each contain a command. Each command is either in the format:
restock product_id quantity
or
purchase product_id quantity
where (product_id) and (quantity) are positive integers.
outputFormat
For each purchase command in the order of appearance, output a single line containing either "SUCCESS" if the purchase could be performed, or "FAILURE" if there was insufficient inventory.## sample
2
restock 1 100
restock 2 200