포럼
문제 ICPC00291

H. Highest Hill

설명

Sweden may not have a particularly impressive mountain range compared to other NCPC countries such as Norway and Iceland, but at least it beats the flatlands of Denmark. The situation is not so clear when comparing other member countries though. For example, is Estonia more mountainous than LithuaniaYes, but not by much! The highest point in Lithuania is Aukštojas Hill, \(293.84\) meters above sea level, while Estonia has the highest peak in the Baltics: Suur Munamägi is \(318\) meters above sea level.? To settle this question, you want to determine which of the two countries has the most impressive mountain peak.

A mountain range is defined by sampling the heights \(h_i\) of \(n\) equidistant points. Within a mountain range, we call a triple of indices \(1 \le i < j < k \le n\) a peak if \(h_i \leq \cdots \leq h_j \geq \cdots \geq h_k\). The height of a peak is defined as the smaller of \(h_j - h_i\) and \(h_j-h_k\).

Given a mountain range, can you find the height of its highest peak?

제약
입력 형식

The first line contains a single integer \(N\) (\(3 \le n \le 200\,000\)), the number of sampled points of the mountain range.

The second and final line contains the heights \(h_1, \dots, h_N\) (\(0 \le h_i \le 318 \cdot 10^9\)) of the sampled points, in nanometers above sea level.

It is guaranteed that the mountain range contains at least one peak.

출력 형식

Output a single integer: the height of the highest peak.

예제 1
입력
11
0 1 2 3 4 5 4 3 2 1 0
출력
5
예제 2
입력
10
29 85 88 12 52 37 19 86 7 44
출력
67
예제 3
입력
3
2147483647 318000000000 2147483647
출력
315852516353
예제 4
입력
3
1 1 1
출력
0
문제 정보

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

출처 ICPC NCPC 2022

평가 및 의견

H. Highest Hill

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

Log in to rate problems.

개별 의견

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

풀이 제출

H. Highest Hill

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