#K10936. Maximum Buildings Visit

    ID: 23357 Type: Default 1000ms 256MiB

Maximum Buildings Visit

Maximum Buildings Visit

You are given an integer \(N\) representing the number of buildings and a list of N integers representing the heights of the buildings. Your task is to determine the maximum number of contiguous buildings you can visit if you start at any building and move only to a building that is of greater than or equal height compared to the current building.

More formally, given a sequence \(a_1, a_2, \ldots, a_N\), find the maximum length of a contiguous subsequence \(a_i, a_{i+1}, \ldots, a_j\) such that \(a_k \leq a_{k+1}\) for all \(i \leq k < j\).

For example, if the input is 5 followed by 1 2 2 3 2, the longest contiguous segment where the building heights are non-decreasing is 1, 2, 2, 3, so the answer is 4.

inputFormat

The input will be provided from standard input (stdin) and consists of two lines:

  1. The first line contains a single integer \(N\), the number of buildings.
  2. The second line contains \(N\) space-separated integers representing the heights of the buildings.

outputFormat

Output a single integer which is the maximum number of contiguous buildings you can visit following the non-decreasing order constraint. The result should be printed to standard output (stdout).

## sample
5
1 2 2 3 2
4

</p>