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

30612번 - Heavy Rainfall 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 (추가 시간 없음) 1024 MB74343249.231%

문제

You're taking part in the development of a novel simulation system that is developed to help with extreme rain in mountainous areas. There have been many occasions of extreme weather recently, and there is a need to calculate the amount of water that will form between mountaintops in the worst-case scenario. This program will be used by experts to aid in predicting the outcome of future extreme weather events.

The program will accept a list of heights that result from discrete measurements from the corresponding mountain ranges. A lake can only form if it's surrounded by higher mountains, and its maximum height will be the minimum of the two surrounding mountains. If a height of 0 is given, it represents the ground. A lake cannot form if any of its parts would be connected to the ground; it would quickly drain otherwise. For each lake formed, its size is the number of 'discrete blocks' that it occupies between the mountaintops.

입력

It's easier to understand all of this if we visualize the problem. As an example, consider we're given as input the height values [3, 0, 6, 1, 2, 8, 6, 7, 3, 1, 2]. The mountains formed could be visualized as below:

The biggest lakes that can form for this mountain range and their corresponding sizes would be the following:

None of the lakes could be bigger, since the water would fall off either side. Also, a lake cannot form in the first gap, as it drains to the ground.

The first line of the input file contains a single integer N, 0 ≤ N ≤ 105, and the second a spaceseparated list of N integers that are the heights of the mountains. Each height value H given is within the range [0, 105].

출력

The output is a single number S (in the range [0, 1010]) that is the sum of the maximally sized lakes that can form.

제한

예제 입력 1

11
3 0 6 1 2 8 6 7 3 1 2

예제 출력 1

11

예제 입력 2

7
7 5 3 1 3 5 7

예제 출력 2

18

힌트

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > Greek Collegiate Programming Contest > GRCPC 2023 4번

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

출처

대학교 대회

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

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