結果

問題 No.2217 Suffix+
ユーザー FromBooskaFromBooska
提出日時 2023-02-18 07:59:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,555 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 1,547 ms
コンパイル使用メモリ 86,816 KB
実行使用メモリ 93,180 KB
最終ジャッジ日時 2023-09-27 02:48:43
合計ジャッジ時間 18,544 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,412 KB
testcase_01 AC 77 ms
71,212 KB
testcase_02 AC 78 ms
71,192 KB
testcase_03 AC 77 ms
71,364 KB
testcase_04 AC 78 ms
71,052 KB
testcase_05 AC 78 ms
71,108 KB
testcase_06 AC 76 ms
71,212 KB
testcase_07 AC 78 ms
71,276 KB
testcase_08 AC 76 ms
71,108 KB
testcase_09 AC 78 ms
71,344 KB
testcase_10 AC 76 ms
71,252 KB
testcase_11 AC 78 ms
71,416 KB
testcase_12 AC 77 ms
71,284 KB
testcase_13 AC 75 ms
71,368 KB
testcase_14 AC 173 ms
78,896 KB
testcase_15 AC 156 ms
78,856 KB
testcase_16 AC 230 ms
83,424 KB
testcase_17 AC 193 ms
81,116 KB
testcase_18 AC 173 ms
80,264 KB
testcase_19 AC 670 ms
87,640 KB
testcase_20 AC 640 ms
86,080 KB
testcase_21 AC 216 ms
76,832 KB
testcase_22 AC 659 ms
87,788 KB
testcase_23 AC 601 ms
83,904 KB
testcase_24 AC 351 ms
92,596 KB
testcase_25 AC 349 ms
92,720 KB
testcase_26 AC 346 ms
92,640 KB
testcase_27 AC 348 ms
92,616 KB
testcase_28 AC 347 ms
92,628 KB
testcase_29 AC 1,173 ms
92,936 KB
testcase_30 AC 1,171 ms
92,932 KB
testcase_31 AC 1,179 ms
93,068 KB
testcase_32 AC 1,176 ms
93,072 KB
testcase_33 AC 1,179 ms
92,972 KB
testcase_34 AC 347 ms
93,084 KB
testcase_35 AC 77 ms
71,196 KB
testcase_36 AC 1,555 ms
93,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 二分探索してみるか?
# 毎回の判定に時間がかかりすぎる気がする

def check(x):
    add = 0
    add_cum = 0
    for i in range(1, N+1):
        if A[i-1]+add_cum < x:
            calc = (x-A[i-1]-add_cum+(i-1))//i
            add += calc
            add_cum += calc*i
    if add <= K:
        return 1
    else:
        return 0
            
N, K = map(int, input().split())
A = list(map(int, input().split()))

#for x in range(0, 10):
#    print(x, check(x))

OK = -1
NG = 10**20
while (NG-OK)>1:
    mid = (NG+OK)//2
    if check(mid) == 1:
        OK = mid
    else:
        NG = mid
print(OK)
0