#C2363. Longest Contiguous Non-Decreasing Subarray
Longest Contiguous Non-Decreasing Subarray
Longest Contiguous Non-Decreasing Subarray
You are given an array of integers. Your task is to compute the length of the longest contiguous subarray such that the elements in the subarray are non-decreasing. In other words, for every pair of adjacent elements in this subarray, a[i] and a[i+1], the condition $$a[i] \leq a[i+1]$$ holds.
Example: Consider the array [1, 2, 2, 3, 1, 4, 4]. The longest contiguous non-decreasing subarray is [1, 2, 2, 3] which has length 4.
You need to read the input from stdin
and print the result to stdout
.
inputFormat
The input consists of two lines:
- The first line contains an 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 array is empty.
outputFormat
Print a single integer denoting the length of the longest contiguous non-decreasing subarray.## sample
7
1 2 2 3 1 4 4
4
</p>