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.