QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22469. Mountain Watching

Statistics

One day, Bessie was gazing off into the distance at the beautiful Wisconsin mountains when she wondered to herself: which is the widest one?

She decided to take $N$ ($1 \le N \le 10,000$) height measurements $H_{i}$ ($1 \le H_{i} \le 1,000,000,000$) sequentially along the horizon using her new Acme Long Distance Geoaltimeter.

A mountain is defined to be a consecutive sequence of $H_{i}$ values which increases (or stays the same) and then decreases (or stays
the same), e.g., 2, 3, 3, 5, 4, 4, 1. It is possible for a mountain on the edge of her field of vision only to increase or only to
decrease in height, as well.

The width of a mountain is the number of measurements it encompasses. Help Bessie identify the widest mountain.

Here's a simple example of a typical horizon:

           *******                   *
          *********                 ***
          **********               *****
          ***********           *********               *
*      *****************       ***********             *** *
**    *******************     *************   * *     *******      *
**********************************************************************
?ddsssuussuussssssddddssddssssuuuuuuuuddddddssududssssuuudduddsssssuds
3211112333677777776543332111112344456765432111212111112343232111111211
aaaaa                     cccccccccccccccccccc eeeeeee    ggggggggg
  bbbbbbbbbbbbbbbbbbbbbbbbbbbb             ddddd ffffffffff  hhhhhhhhh

The mountains are marked 'a', 'b', etc. Obviously, mountain b is widest with width 28.

Hint: Sometimes it's easiest to find a mountain's width by knowing where its highest parts are.

Input

  • Line 1: A single integer: $N$
  • Lines $2..N+1$: Line $i+1$ contains a single integer: $H_{i}$

Output

  • Line 1: A single line with a single integer that is the width of the widest mountain.

Examples

Input 1

7
3
2
3
5
4
1
6

Output 1

5

The height measurements are 3, 2, 3, 5, 4, 1, 6.

The widest mountain consists of the measurements 2, 3, 5, 4, 1. Other mountains include 3, 2 and 1, 6

Problem credits: Jeffrey Wang, 2009

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.