SRM 722, D2, 250-Pointer (HillClimber)

James S. Plank

Thu Oct 12 21:42:55 EDT 2017
This is a "run through the vector, keeping track of stuff" problem. When you're solving this, think about what "stuff" you want to keep track of -- there are really two things:
  1. The longest number of consecutive uphill segments that you have seen.
  2. The current number of consecutive uphill segments that you are looking at.
Since you calculate whether a segment is uphill by looking at the difference between two consecutive vector entries, start your for loop at an index of 1 and not 0. You will always look at an entry and the one before it.