#K61137. Maximum Contiguous Decreasing Buildings

    ID: 31243 Type: Default 1000ms 256MiB

Maximum Contiguous Decreasing Buildings

Maximum Contiguous Decreasing Buildings

You are given a series of buildings in a row, each with a specified height. Your task is to determine the maximum number of contiguous buildings that are in strictly decreasing order.

Formally, given an integer \(N\) and a sequence of heights \( a_1, a_2, \dots, a_N \), find the largest integer \(k\) such that there exists an index \(i\) with \( a_i > a_{i+1} > \cdots > a_{i+k-1} \). If \(N = 0\), output \(0\).

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  • The first line contains a single integer \(N\) representing the number of buildings.
  • The second line contains \(N\) space-separated integers representing the heights of the buildings. If \(N = 0\), the second line will be empty.

outputFormat

Output a single integer to standard output (stdout) which represents the maximum number of contiguous buildings that have strictly decreasing heights.

## sample
8
4 3 2 3 2 1 0 1
4