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

31448번 - Ascending hike 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 1024 MB1841199968.276%

문제

Participating in the Olympics requires training, e.g., climbing from deep valleys to high peaks. Hence, you decided to go out for a hike in which you would be continuously walking on an upward slope, with the largest possible elevation gain.

You have noted the altitude of several remarkable points through which your hike would go: these altitudes are pairwise distinct integers $A_1, A_2, \dots , A_N$. The slope between the $k$th and $(k + 1)$th remarkable points is upward if $A_k < A_{k+1},ドル and downward if $A_k > A_{k+1}$ . Given this list of altitudes, what is the maximal elevation gain of a continuously upward slope on your hike?

입력

The input consists of two lines. The first line contains the number $N$. The second line contains $N$ space-separated integers $A_1, A_2, \dots , A_N$.

출력

The output should contain a single line, consisting of a single number: the maximal integer $G$ for which there exist integers $k, k + 1, k + 2, \dots , \ell$ such that $A_k < A_{k+1} < A_{k+2} < \dots < A_{\ell} = A_k + G$.

제한

  • 2ドル \le N \le 1,円 000,円 000$
  • 0ドル \le A_k \le 1,円 000,円 000,円 000$ for all $k ⩽ N$

예제 입력 1

9
3 4 5 8 1 2 7 6 9

예제 출력 1

6

예제 입력 2

3
8 5 3

예제 출력 2

0

힌트

출처

ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 2023-2024 연습 세션 PA번

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

출처

대학교 대회

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

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