QOJ.ac

QOJ

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

#22469. 观山

Statistics

一天,Bessie 眺望远处美丽的 Wisconsin 群山,心想:哪座最宽?

她决定用新买的 Acme Long Distance Geoaltimeter 沿地平线依次测量 $N$($1 \le N \le 10,000$)个高度 $H_{i}$($1 \le H_{i} \le 1,000,000,000$)。

山定义为一段连续的 $H_{i}$,先递增(或不变),再递减(或不变),如 2, 3, 3, 5, 4, 4, 1。视野边缘的山也可能只递增或只递减。

山宽为包含的测量值数量。请帮 Bessie 找出最宽的山。

下面是一个典型地平线的简单例子:

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

山用 'a'、'b' 等标出。显然山 b 最宽,宽度 28。

提示:有时知道山的最高部分在哪,最容易求山宽。

输入格式

  • 第 1 行:一个整数 $N$。

  • 第 $2..N+1$ 行:第 $i+1$ 行一个整数 $H_{i}$。

输出格式

  • 第 1 行:一行一个整数,最宽山的宽度。

样例

输入格式 1

7
3
2
3
5
4
1
6

输出格式 1

5

说明

高度为 3, 2, 3, 5, 4, 1, 6。

最宽山包含 2, 3, 5, 4, 1。其他山包括 3, 2 和 1, 6。

题目作者: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.