#C7507. Longest Non-Decreasing Subarray
Longest Non-Decreasing Subarray
Longest Non-Decreasing Subarray
You are given an array of integers. Your task is to find the length of the longest contiguous subarray that is non-decreasing. Formally, for an array \(a_1, a_2, \dots, a_n\), you need to determine the maximum integer \(L\) such that there exists an index \(i\) with \(a_i \le a_{i+1} \le \dots \le a_{i+L-1}\).
The subarray must consist of consecutive elements from the original array. If the array is empty, the answer is 0.
inputFormat
The input is read from standard input (stdin) and consists of two lines. 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 elements of the array.
If \(n = 0\), then the second line will be absent and you should output 0.
outputFormat
Output a single integer to standard output (stdout) — the length of the longest non-decreasing contiguous subarray.
## sample6
2 2 1 3 4 1
3