結果

問題 No.2217 Suffix+
ユーザー もちふわゆるゆる
提出日時 2023-02-18 23:42:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 92,288 KB
最終ジャッジ日時 2024-07-20 06:05:31
合計ジャッジ時間 4,825 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math
input = lambda: sys.stdin.readline()[:-1]
def MI(): return map(int, input().split())
inf = 10**18

n,k = MI()
a = list(MI())

def isok(mid):
    now = 0
    cnt = 0
    for left in range(n):
        mn = a[left] + now
        if mn<mid:
            tmp = -(-(mid-mn)//(left+1))
            cnt += tmp
            now += (left+1)*tmp
    
    if cnt<=k:
        return True
    else: return False

l,r = -1, 2*10**15
while abs(l-r)>1:
    mid = (l+r)//2
    if isok(mid): l = mid
    else: r = mid
print(l)
0