#K14191. Consecutive Buildings

    ID: 24080 Type: Default 1000ms 256MiB

Consecutive Buildings

Consecutive Buildings

In this problem, you are given an integer n representing the number of buildings, along with a list of n integers that denote the heights of these buildings. Starting from the first building, you can only move to the next building if its height is greater than or equal to the current one. Your task is to determine the maximum number of consecutive buildings that can be visited under this constraint.

Formally, let the heights be given as \(h_1, h_2, \ldots, h_n\). You start at \(h_1\) and you can move to \(h_{i+1}\) if \(h_{i+1} \geq h_i\). The answer is the largest index \(k\) such that this property holds for all \(1 \leq i < k\). If at any point the condition fails, you must stop.

inputFormat

The input is given in the following format from standard input (stdin):

n
h1 h2 h3 ... hn

Where n is the number of buildings, and the second line contains n space-separated integers representing the heights of the buildings.

outputFormat

Output a single integer to standard output (stdout) which represents the maximum number of consecutive buildings that can be visited starting from the first building.

## sample
6
1 2 2 3 5 1
5