QOJ.ac

QOJ

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

#22469. Obserwacja gór

Statistics

Pewnego dnia Bessie patrzyła w dal na piękne góry Wisconsin i zastanawiała się, która jest najszersza.

Postanowiła kolejno zmierzyć $N$ ($1 \le N \le 10,000$) wysokości $H_{i}$ ($1 \le H_{i} \le 1,000,000,000$) wzdłuż horyzontu nowym Acme Long Distance Geoaltimeter.

Góra to kolejne wartości $H_{i}$, które rosną (lub pozostają takie same), a następnie maleją (lub pozostają takie same), np. 2, 3, 3, 5, 4, 4, 1. Na brzegu pola widzenia mogą tylko rosnąć lub tylko maleć.

Szerokość to liczba zawartych pomiarów. Pomóż Bessie znaleźć najszerszą.

Prosty przykład typowego horyzontu:

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

Góry oznaczono 'a', 'b' itd. Oczywiście b jest najszersza, ma szerokość 28.

Wskazówka: czasem najłatwiej znaleźć szerokość, znając położenie najwyższych części.

Wejście

  • Wiersz 1: jedna liczba całkowita $N$.

  • Wiersze $2..N+1$: wiersz $i+1$ zawiera jedną liczbę całkowitą $H_{i}$.

Wyjście

  • Wiersz 1: jeden wiersz z liczbą całkowitą, szerokością najszerszej góry.

Przykład

Wejście 1

7
3
2
3
5
4
1
6

Wyjście 1

5

Uwagi

Wysokości to 3, 2, 3, 5, 4, 1, 6.

Najszersza zawiera 2, 3, 5, 4, 1. Inne to 3, 2 i 1, 6.

Autor zadania: 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.