#K94147. Pillar Climbing Challenge
Pillar Climbing Challenge
Pillar Climbing Challenge
You are given a sequence of pillars with various heights. Starting from any pillar, you can move to the next pillar only if its height is equal to or greater than the current one. Your task is to compute the maximum number of consecutive pillars (including the starting pillar) that can be traversed under this rule.
Formally, given an array (a_0, a_1, \dots, a_{n-1}) of integers representing the heights of the pillars, find the maximum length (L) of a contiguous segment (a_i, a_{i+1}, \dots, a_j) such that (a_k \le a_{k+1}) for all (i \le k < j). If no pillars are provided (i.e. (n = 0)), then the answer is 0.
inputFormat
The input is read from standard input and consists of two parts:
1. The first line contains a single integer (n) representing the number of pillars.
2. If (n > 0), the second line contains (n) space-separated integers representing the heights of the pillars.
outputFormat
Output to standard output a single integer representing the maximum number of consecutive pillars that can be traversed under the condition that each subsequent pillar is of equal or greater height than the current one.## sample
6
4 4 3 2 5 7
3