Maximum Climb
InterviewTime limit1sMemory limit1024 MB
Given N course heights, find the largest difference between the end and start of a run of consecutive strictly increasing heights.
- Level
Easy2 of 10
- Topics
- Array, Implementation
- Solved
- No attempts yet
Problem
One of the most important features of ski, running, and cycling marathons is the course elevation profile, especially its maximum climb.
The elevation profile gives the heights , , , of course points. A climb is a sequence of consecutive points where each point is strictly higher than the one before it. The height of a climb is the difference between the heights at its start and end.
Write a program that finds the maximum climb height in the given profile.
Input
The first line contains the number of points (). The next lines contain the integer heights () of the points in order from start to finish, one per line.
Output
Print one integer: the maximum climb height, that is, the maximum difference over with . If there is no climb at all, print 0. (haha :)