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

23774번 - Heating Up 다국어

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

문제

Jonas just entered his first chilli-eating contest. He is presented with a pizza consisting of $n$ slices, numbered from 1ドル$ to $n,ドル each containing a selection of chilli peppers. Initially slices $i$ and $i+1$ are adjacent on the plate (where 1ドル \leq i < n$), and so are slices 1ドル$ and $n$. According to the contest rules only one slice can be consumed at a time, and the slice must be finished in its entirety before a new slice is started. Jonas is allowed to pick any slice to eat first, but after that he is only allowed to eat slices that have at most one remaining adjacent slice.

The spiciness of each slice is measured in Scoville Heat Units (SHU). Jonas has a certain spiciness tolerance, also measured in SHU, which corresponds to the spiciness of the spiciest slice that Jonas can tolerate eating. He has also noticed that, after eating a slice of $k$ SHU, his tolerance immediately increases by $k$.

In order to win the contest, Jonas would like to finish all the slices of his pizza. Help him determine the minimum initial spiciness tolerance necessary to do so while abiding by the contest rules.

입력

The input consists of:

  • One line with an integer $n$ (3ドル \le n \le 5 \cdot 10^{5}$), the number of pizza slices.
  • One line with $n$ integers $s_{1}, s_{2}, \ldots, s_{n}$ (0ドル \le s_{i} \le 10^{13}$), where $s_i$ is the spiciness of the $i$th slice in SHU.

출력

Output the minimum initial spiciness tolerance in SHU that Jonas needs in order to be able to eat all slices of the pizza.

제한

예제 입력 1

5
5 0 10 6 1

예제 출력 1

4

예제 입력 2

7
20 23 7 2 3 7 1

예제 출력 2

2

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2021 H번

  • 문제를 만든 사람: Alexander Dietsch, Bjarki Ágúst Guðmundsson
(追記) (追記ここまで)

출처

대학교 대회

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

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