#C7880. Vending Machine Simulator
Vending Machine Simulator
Vending Machine Simulator
In this problem, you are required to simulate the operation of a simple vending machine. The machine processes a series of transactions provided as input. Each transaction is given on a separate line and follows the format:
where:
- n$$ is the required amount to purchase a snack,
- $$c_1, c_2, \ldots, c_m$$ are the values of the inserted coins. $$
The input terminates with a transaction where $$n = 0$$ (this transaction should not be processed).
inputFormat
The input consists of multiple lines. Each line represents a transaction with the format:
n m c1 c2 ... cm
The sequence ends with a line starting with 0.
outputFormat
For each transaction (except the terminating one), print a line containing either "Dispensing snack" if the sum of the coins equals the required amount, or "Insufficient amount" otherwise.## sample
30 3 25 5
50 2 25 25
20 4 5 5 5 5
0
Dispensing snack
Dispensing snack
Dispensing snack
</p>