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.