結果

問題 No.2217 Suffix+
ユーザー mkawa2mkawa2
提出日時 2023-02-17 21:43:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,214 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 86,520 KB
実行使用メモリ 91,104 KB
最終ジャッジ日時 2023-09-26 18:58:10
合計ジャッジ時間 6,126 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,960 KB
testcase_01 AC 70 ms
70,832 KB
testcase_02 AC 70 ms
70,988 KB
testcase_03 AC 70 ms
70,892 KB
testcase_04 AC 70 ms
70,876 KB
testcase_05 AC 70 ms
70,688 KB
testcase_06 AC 71 ms
70,692 KB
testcase_07 AC 71 ms
70,980 KB
testcase_08 AC 71 ms
70,996 KB
testcase_09 AC 77 ms
71,088 KB
testcase_10 AC 72 ms
70,964 KB
testcase_11 AC 72 ms
71,024 KB
testcase_12 AC 72 ms
70,692 KB
testcase_13 AC 73 ms
71,128 KB
testcase_14 AC 82 ms
77,412 KB
testcase_15 AC 81 ms
77,908 KB
testcase_16 AC 88 ms
82,268 KB
testcase_17 AC 85 ms
79,656 KB
testcase_18 AC 85 ms
78,664 KB
testcase_19 AC 128 ms
86,720 KB
testcase_20 AC 122 ms
84,900 KB
testcase_21 AC 85 ms
75,748 KB
testcase_22 AC 122 ms
86,020 KB
testcase_23 AC 121 ms
82,788 KB
testcase_24 AC 109 ms
90,972 KB
testcase_25 AC 109 ms
90,416 KB
testcase_26 AC 106 ms
90,748 KB
testcase_27 AC 106 ms
90,608 KB
testcase_28 AC 105 ms
90,856 KB
testcase_29 AC 189 ms
91,056 KB
testcase_30 AC 187 ms
91,104 KB
testcase_31 AC 193 ms
90,908 KB
testcase_32 AC 190 ms
90,904 KB
testcase_33 AC 191 ms
91,072 KB
testcase_34 AC 103 ms
90,560 KB
testcase_35 AC 71 ms
71,004 KB
testcase_36 AC 162 ms
90,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

def binary_search(l, r, minimize):
    if minimize: l -= 1
    else: r += 1
    while l+1 < r:
        m = (l+r)//2
        if ok(m) ^ minimize: l = m
        else: r = m
    if minimize: return r
    return l

def ok(m):
    cnt = 0
    s = 0
    for i, a in enumerate(aa, 1):
        if a+s >= m: continue
        cur = (m-a-s+i-1)//i
        cnt += cur
        s += i*cur
        if cnt > k: return False
    return True

n, k = LI()
aa = LI()

print(binary_search(0, 2*10**14, False))
0