Woburn Challenge 2017-18 Round 4 - Junior Division
Problem 2: Anger Management
Bruce Banner is a scientist with a bit of a problem. Whenever he becomes too angry, he transforms into a large green creature with superhuman strength, known as the Hulk! This can be very useful when he's helping the Avengers battle against the forces of evil, but isn't so useful in his daily life.
Natasha Romanova, the Black Widow, has become concerned that Bruce may be undergoing his transformation too often, so she's going to monitor his activities in secret over the course of one day. She's noticed that Bruce's mind essentially keeps track of an "anger level", an integer which starts at 0 at the beginning of each day. During a particular day, Bruce will undergo a sequence of N (1 ≤ N ≤ 100) experiences after waking up, with the i-th one causing his anger level to increase by Ai (−5 ≤ Ai ≤ 5). Note that his anger level may become negative during the day.
Bruce takes the form of the Hulk whenever his anger level is 10 or greater. This means that he transforms into the Hulk whenever his anger level goes from being less than 10 to being greater than or equal to 10. Natasha is interested in counting the number of times that this transformation takes place (in other words, the number of experiences which cause Bruce to go from not being the Hulk to suddenly being the Hulk). Can you help her count them?
The first line of input consists of a single integer, N.
N lines follow, the i-th of which consists of a single integer, Ai, for i = 1..N.
Output a single integer, the number of times which Bruce Banner transforms into the Hulk.
6 4 4 3 2 -4 1
Bruce transforms into the Hulk as a result of the 3rd experience (which increases his anger level from 8 to 11), and again as a result of the 6th experience (which increases his anger level from 9 to 10).
Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Apr 20, 2018
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3