#C5961. Longest Non-decreasing Segments

    ID: 49668 Type: Default 1000ms 256MiB

Longest Non-decreasing Segments

Longest Non-decreasing Segments

Given several test cases, each containing a sequence of distances recorded during an activity, the task is to determine the length of the longest continuous segment in which each subsequent distance is not less than the previous one. Formally, for a given sequence \(a_1, a_2, \ldots, a_n\), find the maximum integer \(L\) such that there exists an index \(i\) (with \(1 \le i \le n-L+1\)) satisfying \(a_j \le a_{j+1}\) for all \(i \le j < i+L-1\).

Input Constraints: The first line contains an integer \(T\), denoting the number of test cases. For each test case, the first line contains an integer \(n\) (the number of distances), followed by a line with \(n\) space-separated integers representing these distances.

Example:

Input:
2
6
5 3 4 8 6 7
5
1 2 3 4 5

Output: 3 5

</p>

inputFormat

The input is read from standard input (stdin). The first line contains a single integer \(T\) representing the number of test cases. Each test case consists of two lines:

  • The first line contains an integer \(n\) denoting the number of distances.
  • The second line contains \(n\) space-separated integers representing the distances.

outputFormat

For each test case, output a single line containing one integer: the length of the longest continuous non-decreasing segment.

The output should be written to standard output (stdout).

## sample
2
6
5 3 4 8 6 7
5
1 2 3 4 5
3

5

</p>