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

32857번 - Memories of Passport Stamps 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB42241751.515%

문제

You just got your new passport, fresh with pages ready to be stamped by immigration officers. Sadly, because your passport has so many pages, immigration officers are too lazy to try to use your pages efficiently, so you may need to get a new passport sooner than you think.

You have some trips prepared. For each trip, when you go through passport control, the immigration officer will look for some contiguous pages, none of which are stamped, and then stamp all of them. Because the officer is lazy, there is no guarantee which contiguous pages get stamped.

Now, your passport no longer has enough contiguous empty pages to satisfy your next trip, so you’re in the process of applying for a new passport. Before you do that, you decide to scan through your passport and reminisce about all the fun trips you had. Your least favorite part of these trips was waiting for immigration officers to stamp your passport.

Leafing through your passport, you remember that you took $k$ trips. There are $n$ contiguous sections of stamped pages. What is the minimum value $s$ such that it is possible for each officer to stamp somewhere between 0ドル$ and $s$ pages (both inclusive), so that you can get exactly the sections of stamped pages that you have in your passport now? Different officers may stamp different numbers of pages, and an officer is allowed to stamp zero pages.

입력

The first line of input contains two integers $n$ (1ドル ≤ n ≤ 10^5$) and $k$ ($n ≤ k ≤ 10^{18}$), where $n$ is the number of contiguous sections of stamped pages, and $k$ is the number of trips you took.

The next $n$ lines each contain a single integer $p$ (1ドル ≤ p ≤ 10^{18}$), the number of contiguous stamped pages in a section of your passport. It is guaranteed your passport will have at most 10ドル^{18}$ stamped pages in total.

출력

Output a single integer, the minimum value $s$ such that it is possible for each officer to stamp somewhere between 0ドル$ and $s$ pages so that you can get exactly the sections of stamped pages that you have in your passport now.

제한

예제 입력 1

3 5
9
12
5

예제 출력 1

6

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2024 Southeast USA Regional Programming Contest > Division 2 M번

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

출처

대학교 대회

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

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