Problems > Longest Non-Decreasing Run

Longest Non-Decreasing Run

Difficulty: 1000 2000 ms 128 MB

implementation

Find the length of the longest contiguous run of non-decreasing values (each element ≥ the previous one).

Input: the first line has an integer N; the second line has N integers separated by spaces.

Output: one integer — the length of the longest such run.

Constraints:

  • 1 ≤ N ≤ 2000
  • −109 ≤ ai ≤ 109

Sample Tests

Input 1
7
2 2 5 3 4 4 1
Output 1
3
Input 2
1
9
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.