Get first user's data.
Decide if it's possible to vend bottle, with correct change. If it's not, say "NO", all done.
If it is, update the amount of change the machine has (because the user gave it a coin, and maybe got given a coin back).
Get next user data, do that again.
Get next user data, do that again.
Get next user data, do that again.
Get next user data, do that again.
Get next user data, do that again...
Until there is no more user data. If there is no more, say "YES".
Do you understand why the answer to this set of data:
1 2 3 4 5 6
|
Example
3
100 1
50 1
50 1
Output:No
|
is No?