#C2017. Maximum Non-Decreasing Days
Maximum Non-Decreasing Days
Maximum Non-Decreasing Days
You are given the number of days n and a sequence of integers representing the number of visitors on each day. Your task is to determine the maximum number of consecutive days during which the number of visitors does not decrease. Formally, you need to find the maximum length of a contiguous subarray such that for every day in the subarray (except the first), the number of visitors is greater than or equal to the previous day.
Input Format: The first line contains an integer n
representing the number of days. The second line contains n
space-separated integers, where each integer is the number of visitors for that day.
Output Format: Output a single integer representing the maximum number of consecutive non-decreasing days.
Constraints:
- 1 ≤ n ≤ 10^5
- Each visitor count is an integer with reasonable bounds.
Mathematical Formulation:
Let the visitors array be \(a_1, a_2, \dots, a_n\). Find the maximum length \(L\) such that there exists an index \(i\) with \(1 \leq i \leq n - L + 1\) where \(a_j \leq a_{j+1}\) for all \(j = i, i+1, \dots, i+L-2\).
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains a single integer
n
, the number of days. - The second line contains
n
space-separated integers representing the number of visitors on each day.
outputFormat
Output a single integer to stdout that represents the maximum number of consecutive days with non-decreasing visitor counts.
## sample1
5
1