#C4997. Longest Non-Decreasing Elevation Segment
Longest Non-Decreasing Elevation Segment
Longest Non-Decreasing Elevation Segment
Given a route of n meters and an array of integers where each integer represents the elevation at each meter, you are required to find the length of the longest contiguous segment of the route where the elevation is non-decreasing. In other words, in this segment, the elevation at each meter is greater than or equal to the previous meter.
Formally, if the elevations are represented as \(a_1, a_2, \dots, a_n\), find the maximum length of the segment \(a_i, a_{i+1}, \dots, a_j\) such that \(a_k \leq a_{k+1}\) for all \(i \leq k < j\).
inputFormat
The input will be provided via stdin and consists of two lines:
- The first line contains an integer n, the number of meters in the route.
- The second line contains n space-separated integers representing the elevation at each meter.
outputFormat
Output a single integer representing the maximum length of a segment where the elevation does not decrease. The answer should be printed to stdout.
## sample8
5 1 2 3 2 3 4 5
4