Editorial for WC '17 Contest 4 J2 - Anger Management


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 can iterate over the sequence of N events while maintaining two pieces of information – Bruce Banner's current anger level a, and the number of times h that he's transformed into the Hulk so far (both of which are initially 0). Upon inputting each A_i, we should check if both a < 10 and a+A_i \ge 10 – if so, it's time to increment h by 1. Either way, we should then increment a by A_i. At the end, we can output the final value of h.


Comments

There are no comments at the moment.