結果
問題 | No.2217 Suffix+ |
ユーザー | もちふわゆるゆる |
提出日時 | 2023-02-18 23:40:00 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,016 bytes |
コンパイル時間 | 1,096 ms |
コンパイル使用メモリ | 87,060 KB |
実行使用メモリ | 127,104 KB |
最終ジャッジ日時 | 2023-09-27 11:58:05 |
合計ジャッジ時間 | 13,353 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
75,484 KB |
testcase_01 | AC | 67 ms
75,352 KB |
testcase_02 | AC | 75 ms
75,808 KB |
testcase_03 | AC | 65 ms
71,240 KB |
testcase_04 | AC | 66 ms
71,308 KB |
testcase_05 | AC | 68 ms
75,284 KB |
testcase_06 | AC | 67 ms
71,588 KB |
testcase_07 | AC | 72 ms
75,344 KB |
testcase_08 | AC | 75 ms
75,632 KB |
testcase_09 | AC | 71 ms
75,272 KB |
testcase_10 | AC | 71 ms
75,720 KB |
testcase_11 | AC | 67 ms
75,256 KB |
testcase_12 | AC | 69 ms
75,024 KB |
testcase_13 | AC | 67 ms
71,584 KB |
testcase_14 | AC | 985 ms
100,616 KB |
testcase_15 | AC | 938 ms
100,724 KB |
testcase_16 | AC | 1,951 ms
127,104 KB |
testcase_17 | AC | 1,408 ms
112,960 KB |
testcase_18 | AC | 1,265 ms
105,864 KB |
testcase_19 | TLE | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
ソースコード
import sys, math input = lambda: sys.stdin.readline()[:-1] def MI(): return map(int, input().split()) inf = 10**18 class BIT: def __init__(self, n): self.size = n self.n0 = 1 << (n.bit_length() - 1) self.tree = [0] * (n + 1) def sum(self, i): i += 1 s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): i += 1 while i <= self.size: self.tree[i] += x i += i & -i def range_sum(self, l, r): return self.sum(r - 1) - self.sum(l - 1) def get(self, i): return self.sum(i) - self.sum(i - 1) def lower_bound(self, x): pos = 0 plus = self.n0 while plus > 0: if pos + plus <= self.size and self.tree[pos + plus] < x: x -= self.tree[pos + plus] pos += plus plus //= 2 return pos # https://ikatakos.com/pot/programming_algorithm/data_structure/binary_indexed_tree # 区間加算 / 区間和 class RangeUpdate: def __init__(self, n): self.p = BIT(n) self.q = BIT(n) def add(self, l, r, x): self.p.add(l, -x * (l-1)) self.p.add(r-1, x * (r-1)) self.q.add(l, x) self.q.add(r-1, -x) def get_sum(self, l, r): sum_p = self.p.sum(r-1) + self.q.sum(r-1) * (r-1) sum_q = self.p.sum(l-1) + self.q.sum(l-1) * (l-1) return sum_p - sum_q n,k = MI() a = list(MI()) def isok(mid): bit = RangeUpdate(n) for i in range(n): bit.add(i, i+1, a[i]) cnt = 0 for left in range(n): mn = bit.get_sum(left, left+1) if mn<mid: tmp = -(-(mid-mn)//(left+1)) cnt += tmp bit.add(left, n, (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)