Editorial for Mock CCC '22 Contest 1 J2 - Biking and Hiking
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.
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.
Time Complexity:
Comments