Editorial for Mock CCC '22 Contest 1 J2 - Biking and Hiking
Submitting an official solution before solving the problem yourself is a bannable offence.
To solve this problem, we can maintain a speed counter.
On uphills, we reduce the counter by one if it is positive. If the counter is , we add one to our answer.
On downhills, we increase the counter by one.
On flat sections, if the counter is , we add one to our answer.