#K58167. Longest Non-Decreasing Segment
Longest Non-Decreasing Segment
Longest Non-Decreasing Segment
You are given several test cases. For each test case, you are provided with a sequence of altitude measurements. Your task is to determine the length of the longest continuous segment in the sequence where the altitudes are non-decreasing.
Formally, given an array of integers \(a_1, a_2, \dots, a_n\), you need to find the maximum length \(L\) such that there exists an index \(i\) with \(1 \le i \le n - L + 1\) for which \[ a_i \le a_{i+1} \le \dots \le a_{i+L-1} \]
The input is provided via standard input and your answer should be written to standard output.
inputFormat
The first line of the input contains an integer T, the number of test cases. Each test case consists of two lines:
- The first line contains a single integer n, representing the number of altitude measurements.
- The second line contains n space-separated integers, representing the altitude measurements.
It is guaranteed that n (\ge) 1.
outputFormat
For each test case, output a single integer on a new line representing the length of the longest contiguous segment where the altitude does not decrease.## sample
3
5
1 2 2 1 2
3
3 3 3
4
4 3 2 3
3
3
2
</p>