#C11637. Longest Continuous Ascent
Longest Continuous Ascent
Longest Continuous Ascent
You are given an integer n representing the number of sections along a hiking trail and a sequence of n integers representing the elevation at each section. Your task is to determine the length of the longest continuous ascending subsequence, where each successive elevation is strictly greater than the previous one.
For example, given the sequence: [2, 2, 1, 3, 4, 1, 5], the longest continuous ascent is [1, 3, 4] which has a length of 3.
Input constraints: You can assume that n ≥ 1 and the elevations are integers. The sequence is provided in one line after n.
The problem can be formalized as finding the maximum value of L such that for some index i (with 1 ≤ i ≤ n − L + 1), the following holds:
[ \forall j \in {i+1, i+2, \ldots, i+L-1},; heights[j] > heights[j-1] ]
inputFormat
The input is given from standard input and consists of two lines:
- The first line contains a single integer n (the number of sections).
- The second line contains n space-separated integers representing the elevations.
outputFormat
Output a single integer which is the length of the longest continuous ascending subsequence. The output should be written to standard output.
## sample7
2 2 1 3 4 1 5
3