結果

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

ソースコード

diff #

n, k = map(int, input().split())
a = list(map(int, input().split()))
l = -1
r = a[0] + k + 1
while r - l > 1:
    c = (l + r) // 2
    cnt = 0
    add = 0
    for i, x in enumerate(a, 1):
        x += add
        if c > x:
            v = (c - x + i - 1) // i
            cnt += v
            add += v * i
    if cnt <= k:
        l = c
    else:
        r = c
print(l)
0