QOJ.ac

QOJ

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

#22469. Ngắm núi

Statistics

Một ngày Bessie ngắm những ngọn núi Wisconsin đẹp ở xa và tự hỏi ngọn nào rộng nhất.

Cô quyết định đo lần lượt $N$ ($1 \le N \le 10,000$) độ cao $H_{i}$ ($1 \le H_{i} \le 1,000,000,000$) dọc đường chân trời bằng Acme Long Distance Geoaltimeter mới.

Một ngọn núi là dãy liên tiếp các $H_{i}$ tăng (hoặc giữ nguyên), rồi giảm (hoặc giữ nguyên), như 2, 3, 3, 5, 4, 4, 1. Ở mép tầm nhìn núi cũng có thể chỉ tăng hoặc chỉ giảm.

Độ rộng là số phép đo núi bao gồm. Giúp Bessie tìm ngọn rộng nhất.

Ví dụ đơn giản về đường chân trời điển hình:

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

Núi được đánh dấu 'a', 'b', v.v. Rõ ràng b rộng nhất, độ rộng 28.

Gợi ý: đôi khi dễ nhất là tìm độ rộng khi biết vị trí những phần cao nhất.

Dữ liệu vào

  • Dòng 1: một số nguyên $N$.

  • Các dòng $2..N+1$: dòng $i+1$ chứa một số nguyên $H_{i}$.

Dữ liệu ra

  • Dòng 1: một dòng với một số nguyên, độ rộng núi rộng nhất.

Ví dụ

Dữ liệu vào 1

7
3
2
3
5
4
1
6

Dữ liệu ra 1

5

Ghi chú

Các độ cao là 3, 2, 3, 5, 4, 1, 6.

Núi rộng nhất gồm 2, 3, 5, 4, 1. Núi khác gồm 3, 2 và 1, 6.

Tác giả bài toán: 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.