Editorial for WC '18 Contest 4 J2 - Life Insurance


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

We'll simulate the battle while maintaining two variables: Mario's current HP (initially 50), and the number of Life Shrooms L consumed so far (initially 0). Upon inputting each value H_i, we should first increase HP by H_i (setting it equal to 50 if it would exceed 50). Then, if HP \le 0, we should set it equal to 10 and increment L by one. After processing all N events in this manner, we can output L.


Comments

There are no comments at the moment.