#P1893. The Widest Mountain
The Widest Mountain
The Widest Mountain
Bessie has taken N (\(1 \le N \le 10,000\)) height measurements with her new long-range mountain height gauge while gazing at the beautiful mountains of Wisconsin. Each height measurement is a positive integer \(H_i\) (\(1 \le H_i \le 1,000,000,000\)).
A mountain is defined as a contiguous sequence of measurements that initially is non-decreasing (i.e., increasing or staying the same) and then becomes non-increasing (i.e., decreasing or staying the same). For instance, the sequence:
[ 2,; 3,; 3,; 5,; 4,; 4,; 1 ]
is considered a mountain with a width of 7. Note that even a strictly non-decreasing or strictly non-increasing sequence is considered a mountain. Also, mountains may overlap.
Your task is to help Bessie find the widest mountain in her sequence of measurements.
Example:
Input: 7 2 3 3 5 4 4 1 Output: 7
inputFormat
The first line contains a single integer N, the number of measurements.
The second line contains N space-separated integers, representing the height measurements \(H_1, H_2, \ldots, H_N\).
outputFormat
Print a single integer representing the width of the widest mountain found in the sequence.
sample
7
2 3 3 5 4 4 1
7