#C5504. Longest Non-Decreasing Subarray

    ID: 49161 Type: Default 1000ms 256MiB

Longest Non-Decreasing Subarray

Longest Non-Decreasing Subarray

You are given the stock prices for n days. Your task is to find the length of the longest contiguous subarray (subsequence) in which the stock prices never decrease. Formally, for an array of prices \(a_1, a_2, \ldots, a_n\), find the maximum length \(L\) such that there exists an index \(i\) (1 \( \leq i \leq n-L+1\)) and for every \(j\) in \(i, i+1, \dots, i+L-1\) we have \(a_j \leq a_{j+1}\) (using 1-indexing, with the convention that a single element counts as non-decreasing).

If no prices are given (i.e. n = 0), the answer is 0.

inputFormat

The first line contains an integer \(n\) (\(n \ge 0\)), the number of days. The second line contains \(n\) space-separated integers, which represent the stock prices on each day. If \(n = 0\), the second line will be empty.

outputFormat

Output a single integer, the length of the longest contiguous subarray in which the stock prices are non-decreasing.

## sample
6
1 2 2 2 3 1
5