結果

問題 No.2217 Suffix+
ユーザー rlangevinrlangevin
提出日時 2023-02-17 21:35:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,263 ms / 2,000 ms
コード長 1,312 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 86,688 KB
実行使用メモリ 117,928 KB
最終ジャッジ日時 2023-09-26 18:45:35
合計ジャッジ時間 18,598 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,980 KB
testcase_01 AC 72 ms
71,076 KB
testcase_02 AC 75 ms
75,496 KB
testcase_03 AC 71 ms
71,228 KB
testcase_04 AC 72 ms
70,776 KB
testcase_05 AC 71 ms
71,144 KB
testcase_06 AC 71 ms
71,140 KB
testcase_07 AC 72 ms
71,132 KB
testcase_08 AC 74 ms
70,976 KB
testcase_09 AC 70 ms
71,232 KB
testcase_10 AC 75 ms
71,144 KB
testcase_11 AC 71 ms
71,108 KB
testcase_12 AC 70 ms
71,060 KB
testcase_13 AC 70 ms
71,256 KB
testcase_14 AC 375 ms
87,704 KB
testcase_15 AC 365 ms
86,816 KB
testcase_16 AC 730 ms
100,348 KB
testcase_17 AC 425 ms
92,220 KB
testcase_18 AC 426 ms
89,940 KB
testcase_19 AC 1,166 ms
109,300 KB
testcase_20 AC 1,003 ms
104,876 KB
testcase_21 AC 233 ms
79,572 KB
testcase_22 AC 1,093 ms
107,788 KB
testcase_23 AC 777 ms
99,472 KB
testcase_24 AC 291 ms
105,140 KB
testcase_25 AC 256 ms
103,480 KB
testcase_26 AC 262 ms
101,020 KB
testcase_27 AC 270 ms
107,024 KB
testcase_28 AC 266 ms
102,600 KB
testcase_29 AC 990 ms
117,504 KB
testcase_30 AC 990 ms
117,628 KB
testcase_31 AC 933 ms
117,724 KB
testcase_32 AC 938 ms
116,760 KB
testcase_33 AC 961 ms
117,928 KB
testcase_34 AC 1,132 ms
111,172 KB
testcase_35 AC 71 ms
71,184 KB
testcase_36 AC 1,263 ms
116,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Fenwick_Tree:
    def __init__(self, n):
        self._n = n
        self.data = [0] * n

    def add(self, p, x):
        assert 0 <= p < self._n
        p += 1
        while p <= self._n:
            self.data[p - 1] += x
            p += p & -p

    def sum(self, l, r):
        assert 0 <= l <= r <= self._n
        return self._sum(r) - self._sum(l)

    def _sum(self, r):
        s = 0
        while r > 0:
            s += self.data[r - 1]
            r -= r & -r
        return s
    
    def get(self, k):
        k += 1
        x, r = 0, 1
        while r < self._n:
            r <<= 1
        len = r
        while len:
            if x + len - 1 < self._n:
                if self.data[x + len - 1] < k:
                    k -= self.data[x + len - 1]
                    x += len
            len >>= 1
        return x

def check(m):
    T = Fenwick_Tree(N)
    cnt = 0
    for i in range(N):
        if A[i] >= m:
            continue
        s = T.sum(0, i + 1)
        v = max(0, (m - A[i] - s + i)//(i + 1))
        cnt += v 
        T.add(i, v * (i + 1))
    return cnt <= K

N, K = map(int, input().split())
A = list(map(int, input().split()))
yes = 0
no = 10 ** 15
while no - yes != 1:
    mid = (yes + no)//2
    if check(mid):
        yes = mid
    else:
        no = mid
print(yes)
0