結果

問題 No.2217 Suffix+
ユーザー chineristAC
提出日時 2023-02-17 23:16:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 82,224 KB
実行使用メモリ 93,392 KB
最終ジャッジ日時 2024-07-19 14:27:00
合計ジャッジ時間 4,331 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import gcd,log

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N,K = mi()
A = li()

def cond(x):
    add = 0
    res = 0
    for i in range(N):
        if A[i]+add < x:
            need = (x-A[i]-add+i)//(i+1)
            res += need
            add += need * (i+1)
    
    return res <= K


ok = 0
ng = 10**17
while ng-ok>1:
    mid = (ok+ng)//2
    if cond(mid):
        ok = mid
    else:
        ng = mid

print(ok)


0