#K95457. Maximum Consecutive Mountains
Maximum Consecutive Mountains
Maximum Consecutive Mountains
You are given a sequence of N mountain heights. A hiker can traverse from one mountain to the next only when the next mountain has a height that is equal or greater than the current mountain. The goal is to determine the maximum number of consecutive mountains the hiker can traverse in the range.
More formally, given an array \(a_1, a_2, \dots, a_N\), you need to find the longest contiguous subsequence such that for every adjacent pair \(a_i\) and \(a_{i+1}\) in the subsequence, the condition
[ a_i \leq a_{i+1} ]
holds true.
If there are no mountains (i.e. \(N = 0\)), the answer is 0.
inputFormat
The first line contains an integer N representing the number of mountains. The second line contains N space-separated integers representing the heights of the mountains.
If N is 0, the second line will be empty.
outputFormat
Output a single integer, the maximum number of consecutive mountains the hiker can traverse.
## sample6
5 4 7 7 1 3
3
</p>