結果

問題 No.2217 Suffix+
ユーザー aaaaaaaaaa2230
提出日時 2023-02-17 21:59:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 943 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 92,096 KB
最終ジャッジ日時 2024-07-19 13:11:59
合計ジャッジ時間 9,537 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
A = list(map(int,input().split()))


def calc(x):
    count = 0
    left = k
    for i,a in enumerate(A,1):
        na = a+count
        if na >= x:
            continue
        need = (x-na+i-1)//i
        if need > left:
            return False
        count += need*i
        left -= need

    return True



l = 0
r = 10**20
while r > l + 1:
    m = (r+l)//2
    if calc(m):
        l = m
    else:
        r = m
print(l)
0