#K7021. Maximum Downward Bridge Walk

    ID: 33258 Type: Default 1000ms 256MiB

Maximum Downward Bridge Walk

Maximum Downward Bridge Walk

You are given an array of N integers where each integer represents the height of a bridge segment. Your task is to determine the maximum number of contiguous segments you can traverse such that each subsequent segment has a height that is less than or equal to the previous one. In other words, you can step from segment A[i-1] to A[i] if and only if (A[i] \le A[i-1]). If there are no segments (i.e., N = 0), the answer is 0.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (N) representing the number of bridge segments. The second line contains (N) space-separated integers denoting the heights of the segments.

outputFormat

Output a single integer: the maximum number of contiguous bridge segments that can be traversed such that each segment's height is less than or equal to the previous one. Print the result to standard output (stdout).## sample

7
5 3 3 2 4 2 1
4