QOJ.ac

QOJ

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

#22469. צפייה בהרים

Statistics

יום אחד Bessie הביטה מרחוק בהרים היפים של Wisconsin ותהתה איזה מהם הרחב ביותר.

היא החליטה למדוד ברצף $N$ ($1 \le N \le 10,000$) גבהים $H_{i}$ ($1 \le H_{i} \le 1,000,000,000$) לאורך האופק באמצעות Acme Long Distance Geoaltimeter החדש שלה.

הר מוגדר כרצף של ערכי $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.