Logo
(追記) (追記ここまで)

9822번 - Global Warming 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB88292642.623%

문제

A scientist wants to study how the rising sea level changes the landscape, in particular, how it changes the number of islands. He first investigates one-dimensional worlds. An onedimensional world is represented by a sequence of non-negative integers <h0, h1, . . . , hn−1>, where each integer hi is the altitude at the location i. The following figure depicts an example of such world represented by the sequence <5, 6, 1, 3, 2, 9, 8>.

Now, if the sea level is at altitude 2.5, there are 3 islands formed by landmass of the first two columns, the fourth column and the last two columns. Furthermore, if the sea level is at altitude 3.5, there are only 2 islands. When the sea level is at altitude x, landmass with altitude x is considered to be submerged under the sea. Hence, if the sea level is at altitude 3, there are 2 islands. Note that having 3 islands is the maximum among all possible sea levels.

Given a one-dimensional world, the scientist wants to find the maximum number of islands among all sea levels.

입력

Your program must read from the standard input. The first line in the input contains the integer n, the total number of integers in the sequence. Next, it is followed by n lines where each line contains an integer. These n lines represent the sequence <h0, h1, . . . , hn−1>. All numbers in the sequence are non-negative and smaller than 230.

출력

Your program must write to the standard output an integer, which is the maximum number of islands.

제한

예제 입력 1

7
5
6
1
3
2
9
8

예제 출력 1

3

힌트

출처

Olympiad > National Olympiad in Informatics (Singapore) > NOI 2013 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /