RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 ICPC00092

H. Heating Up

설명

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
출력
4
예제 2
입력
7
20 23 7 2 3 7 1
출력
2
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2021

평가 및 의견

H. Heating Up

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

H. Heating Up

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8