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.
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 ), and the number of Life Shrooms
consumed so far (initially
). Upon inputting each value
, we should first increase HP by
(setting it equal to
if it would exceed
). Then, if HP
, we should set it equal to
and increment
by one. After processing all
events in this manner, we can output
.
Comments