結果
問題 | No.1705 Mode of long array |
ユーザー | NatsubiSogan |
提出日時 | 2021-10-10 17:41:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 580 ms / 3,000 ms |
コード長 | 2,451 bytes |
コンパイル時間 | 431 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 101,828 KB |
最終ジャッジ日時 | 2024-09-14 13:17:41 |
合計ジャッジ時間 | 22,279 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
67,456 KB |
testcase_01 | AC | 73 ms
67,328 KB |
testcase_02 | AC | 71 ms
67,328 KB |
testcase_03 | AC | 148 ms
79,744 KB |
testcase_04 | AC | 136 ms
78,848 KB |
testcase_05 | AC | 160 ms
79,104 KB |
testcase_06 | AC | 213 ms
80,100 KB |
testcase_07 | AC | 216 ms
80,032 KB |
testcase_08 | AC | 210 ms
80,128 KB |
testcase_09 | AC | 207 ms
79,772 KB |
testcase_10 | AC | 209 ms
80,080 KB |
testcase_11 | AC | 224 ms
80,188 KB |
testcase_12 | AC | 214 ms
80,048 KB |
testcase_13 | AC | 560 ms
95,968 KB |
testcase_14 | AC | 497 ms
87,336 KB |
testcase_15 | AC | 472 ms
84,240 KB |
testcase_16 | AC | 529 ms
86,572 KB |
testcase_17 | AC | 432 ms
83,124 KB |
testcase_18 | AC | 443 ms
84,080 KB |
testcase_19 | AC | 569 ms
87,808 KB |
testcase_20 | AC | 461 ms
85,236 KB |
testcase_21 | AC | 475 ms
92,168 KB |
testcase_22 | AC | 580 ms
99,032 KB |
testcase_23 | AC | 232 ms
78,848 KB |
testcase_24 | AC | 239 ms
78,976 KB |
testcase_25 | AC | 235 ms
79,232 KB |
testcase_26 | AC | 236 ms
78,720 KB |
testcase_27 | AC | 239 ms
79,232 KB |
testcase_28 | AC | 232 ms
78,848 KB |
testcase_29 | AC | 238 ms
78,976 KB |
testcase_30 | AC | 237 ms
78,848 KB |
testcase_31 | AC | 232 ms
78,976 KB |
testcase_32 | AC | 238 ms
79,616 KB |
testcase_33 | AC | 409 ms
100,420 KB |
testcase_34 | AC | 384 ms
100,916 KB |
testcase_35 | AC | 399 ms
100,548 KB |
testcase_36 | AC | 410 ms
100,288 KB |
testcase_37 | AC | 403 ms
100,660 KB |
testcase_38 | AC | 410 ms
100,416 KB |
testcase_39 | AC | 428 ms
100,672 KB |
testcase_40 | AC | 407 ms
100,672 KB |
testcase_41 | AC | 409 ms
100,544 KB |
testcase_42 | AC | 413 ms
100,668 KB |
testcase_43 | AC | 384 ms
101,580 KB |
testcase_44 | AC | 393 ms
101,568 KB |
testcase_45 | AC | 400 ms
101,424 KB |
testcase_46 | AC | 397 ms
101,444 KB |
testcase_47 | AC | 423 ms
101,456 KB |
testcase_48 | AC | 425 ms
101,828 KB |
testcase_49 | AC | 531 ms
100,800 KB |
testcase_50 | AC | 519 ms
100,928 KB |
testcase_51 | AC | 513 ms
100,544 KB |
testcase_52 | AC | 520 ms
100,668 KB |
testcase_53 | AC | 499 ms
101,060 KB |
ソースコード
import typing class SegmentTree: def __init__( self, lis: list, ele: typing.Any, op: typing.Callable[[typing.Any, typing.Any], typing.Any]) -> None: self.n = len(lis) self.log = (self.n - 1).bit_length() self.size = 1 << self.log self.op = op self.ele = ele self.tree = self._build(lis) def _build(self, lis: list) -> list: res_tree = [self.ele] * (2 * self.size) for i, a in enumerate(lis): res_tree[self.size + i] = a for i in range(1, self.size)[::-1]: res_tree[i] = self.op(res_tree[2 * i], res_tree[2 * i + 1]) return res_tree def __getitem__(self, i: int) -> None: return self.tree[self.size + i] def __setitem__(self, p: int, x: int) -> None: p += self.size self.tree[p] = x for i in range(1, self.log + 1): self.tree[p >> i] = self.op(self.tree[2 * (p >> i)], self.tree[2 * (p >> i) + 1]) def prod(self, l: int, r: int) -> typing.Any: l += self.size r += self.size L = R = self.ele while l < r: if l & 1: L = self.op(L, self.tree[l]) l += 1 if r & 1: r -= 1 R = self.op(self.tree[r], R) l >>= 1 r >>= 1 return self.op(L, R) def all_prod(self) -> typing.Any: return self.tree[1] def max_right(self, l: int, f) -> int: if l == self.n: return self.n l += self.size sm = self.ele while True: while l % 2 == 0: l >>= 1 if not f(self.op(sm, self.tree[l])): while l < self.size: l *= 2 if f(self.op(sm, self.tree[l])): sm = self.op(sm, self.tree[l]) l += 1 return l - self.size sm = self.op(sm, self.tree[l]) l += 1 if (l & -l) == l: return self.n def min_left(self, r: int, f) -> int: if r == 0: return 0 r += self.size sm = self.ele while True: r -= 1 while r > 1 and (r % 2): r >>= 1 if not f(self.op(self.tree[r], sm)): while r < self.size: r = 2 * r + 1 if f(self.op(self.tree[r], sm)): sm = self.op(self.tree[r], sm) r -= 1 return r + 1 - self.size sm = self.op(self.d[r], sm) if (r & -r) == r: return 0 n, m = map(int, input().split()) a = list(map(int, input().split())) a = [(a[i], i + 1) for i in range(m)] def op(a, b): return a if a[0] > b[0] else b ST = SegmentTree(a, [-1, -1], op) for _ in range(int(input())): t, x, y = map(int, input().split()) if t == 1: ST[x - 1] = [ST[x - 1][0] + y, ST[x - 1][1]] if t == 2: ST[x - 1] = [ST[x - 1][0] - y, ST[x - 1][1]] if t == 3: print(ST.all_prod()[1])