The Case of the Game
InterviewTime limit2sMemory limit1024 MB
Track the ammo count through save, load, shoot, and ammo actions, and print the count after each action.
- Level
Easy2 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Problem
Sherlock: You killed a man.
John: I know. It is certain. But he was not an important man.
John Watson has psychosomatic pain in his leg, so his personal psychiatrist advised him to play shooter games. Watson is an excellent shot, but he struggles with mental tasks. He cannot remember how many rounds he has left.
In the game, you can save, load the last save, pick up a crate of rounds, and shoot one round. After a load, the ammo count becomes the same as it was at the last save. If a load happens before the first save, the ammo count becomes zero.
After each action by John, report how many rounds he has at that moment. Initially he has zero rounds. It is guaranteed that Watson never shoots when he has no ammo.
Input
The first line contains two integers and (, ), where is the number of John's actions and is the number of rounds in one crate. Each of the next lines contains , which is one of the following:
save: save the gameload: load the last saveshoot: shoot one roundammo: pick up a crate with rounds
Output
For each action, print the number of rounds Watson has left after that action.
Hint
The first test group is checked when the solution is submitted and is worth 50 points. Points for this group are awarded only if all tests in the group pass. No test in this group contains save or load commands.
The second test group is checked after the olympiad ends and is worth 50 points. Points for this group are awarded only if all tests in the group pass.