시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
3 초 (추가 시간 없음) | 1024 MB | 65 | 36 | 31 | 57.407% |
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:
Output the minimum initial spiciness tolerance in SHU that Jonas needs in order to be able to eat all slices of the pizza.
5 5 0 10 6 1
4
7 20 23 7 2 3 7 1
2
ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2021 H번