Memories of Passport Stamps

시간 제한1초메모리 제한2048 MB

요약
n개의 도장 구간의 길이가 주어지고 총 k번의 도장이 있었다. 각 도장이 0장부터 s장까지 찍을 수 있다고 할 때, 주어진 구간을 정확히 만들 수 있는 최소 s를 구한다.
난이도

어려움10점 중 8점

유형
그리디, 이분 탐색, 수학
정답자
아직 제출이 없습니다

문제

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 kk trips. There are nn contiguous sections of stamped pages. What is the minimum value ss such that it is possible for each officer to stamp somewhere between 00 and ss 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 nn (1≤n≤1051 ≤ n ≤ 10^5) and kk (n≤k≤1018n ≤ k ≤ 10^{18}), where nn is the number of contiguous sections of stamped pages, and kk is the number of trips you took.

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

출력

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

예제1

  1. 예제 1

    입력
    3 5
    9
    12
    5
    
    예상 출력
    6