#C505. Longest Non-Decreasing Sequence
Longest Non-Decreasing Sequence
Longest Non-Decreasing Sequence
You are given one or more test cases. In each test case, a list of integers is provided. Your task is to find the length of the longest non-decreasing contiguous subsequence for each test case.
A sequence \(a_1, a_2, \ldots, a_n\) is non-decreasing if \(a_i \le a_{i+1}\) for all \(1 \le i < n\). For each test case, you need to output a single integer on a new line representing the maximum length of a contiguous segment that maintains this property.
Note: An empty list has a result of 0 and a single-element list has a result of 1.
inputFormat
The first line contains an integer \(T\) representing the number of test cases. Each test case consists of two lines. The first line contains an integer \(N\) indicating the number of elements in the array. The second line contains \(N\) space-separated integers representing the elements of the array. If \(N = 0\), the second line may be empty.
outputFormat
For each test case, output a single integer on a new line which is the length of the longest non-decreasing contiguous subsequence.
## sample2
5
100 105 110 108 115
6
1 2 2 3 1 5
3
4
</p>