#K38312. Longest Non-Decreasing Subarray
Longest Non-Decreasing Subarray
Longest Non-Decreasing Subarray
You are given a sequence of N integers which represent the heights of flowers. Your task is to determine the length of the longest contiguous subarray where the sequence is non-decreasing, i.e., for every pair of consecutive elements \(a_i\) and \(a_{i+1}\), it holds that \(a_i \le a_{i+1}\).
Input Format:
- The first line contains a single integer \(N\), representing the number of elements in the array.
- The second line contains \(N\) space-separated integers representing the heights.
Output Format:
- Output a single integer, the length of the longest contiguous non-decreasing subarray.
Note: If \(N = 0\), the output should be 0.
For example:
Input: 6 1 2 2 3 2 2</p>Output: 4
inputFormat
The input starts with an integer \(N\) on the first line. The second line contains \(N\) space-separated integers denoting the sequence of flower heights.
outputFormat
Output a single integer representing the length of the longest contiguous non-decreasing subarray.
## sample6
1 2 2 3 2 2
4
</p>