結果
問題 | No.2942 Sigma Music Game Level Problem |
ユーザー | miya145592 |
提出日時 | 2024-10-18 23:26:43 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,410 ms / 6,000 ms |
コード長 | 2,244 bytes |
コンパイル時間 | 1,212 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 292,188 KB |
最終ジャッジ日時 | 2024-11-15 06:57:25 |
合計ジャッジ時間 | 31,714 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
66,304 KB |
testcase_01 | AC | 59 ms
66,304 KB |
testcase_02 | AC | 59 ms
66,176 KB |
testcase_03 | AC | 60 ms
66,048 KB |
testcase_04 | AC | 62 ms
66,176 KB |
testcase_05 | AC | 61 ms
66,176 KB |
testcase_06 | AC | 59 ms
66,432 KB |
testcase_07 | AC | 60 ms
66,560 KB |
testcase_08 | AC | 105 ms
82,176 KB |
testcase_09 | AC | 84 ms
75,520 KB |
testcase_10 | AC | 78 ms
73,728 KB |
testcase_11 | AC | 953 ms
186,132 KB |
testcase_12 | AC | 2,540 ms
252,176 KB |
testcase_13 | AC | 2,976 ms
227,572 KB |
testcase_14 | AC | 1,175 ms
216,040 KB |
testcase_15 | AC | 533 ms
195,556 KB |
testcase_16 | AC | 2,605 ms
217,536 KB |
testcase_17 | AC | 495 ms
118,236 KB |
testcase_18 | AC | 1,816 ms
190,960 KB |
testcase_19 | AC | 3,410 ms
271,052 KB |
testcase_20 | AC | 577 ms
172,660 KB |
testcase_21 | AC | 3,137 ms
291,944 KB |
testcase_22 | AC | 3,234 ms
292,188 KB |
testcase_23 | AC | 569 ms
106,532 KB |
testcase_24 | AC | 56 ms
66,828 KB |
testcase_25 | AC | 56 ms
66,304 KB |
testcase_26 | AC | 1,188 ms
243,532 KB |
ソースコード
class SegTree: def __init__(self, op, e, n, v=None): self._n = n self._op = op self._e = e self._log = (n - 1).bit_length() self._size = 1 << self._log self._d = [self._e()] * (self._size << 1) if v is not None: for i in range(self._n): self._d[self._size + i] = v[i] for i in range(self._size - 1, 0, -1): self._d[i] = self._op(self._d[i << 1], self._d[i << 1 | 1]) def set(self, p, x): p += self._size self._d[p] = x while p: l, r = p, p^1 if l > r: l, r = r, l self._d[p >> 1] = self._op(self._d[l], self._d[r]) p >>= 1 def get(self, p): return self._d[p + self._size] #[l, r)の区間で求める def prod(self, l, r): sml, smr = self._e(), self._e() l += self._size r += self._size while l < r: if l & 1: sml = self._op(sml, self._d[l]) l += 1 if r & 1: r -= 1 smr = self._op(self._d[r], smr) l >>= 1 r >>= 1 return self._op(sml, smr) def all_prod(self): return self._d[1] def op(x, y): return x+y def e(): return 0 BASE = 21 MASK = (1<<BASE)-1 def op2(x, y): xi, xc = x>>BASE, x&MASK yi, yc = y>>BASE, y&MASK ret = ((xi+yi)<<BASE) | (xc+yc) return ret def e2(): return 0 import sys input = sys.stdin.readline N, Q, L = map(int, input().split()) A = list(map(int, input().split())) query = [list(map(int, input().split())) for _ in range(Q)] dp = [0 for _ in range(200001)] for a in A: dp[a] += 1 for i in range(200001): c = dp[i] dp[i] = ((c*i)<<BASE) | c ST = SegTree(op2, e2, 200001, dp) flag = True for q in query: t = q[0] if t==1: l = q[1] v = ST.get(l) vi, vc = v>>BASE, v&MASK vi += l vc += 1 v = (vi<<BASE)|vc ST.set(l, v) elif t==2: l, r = q[1:] v = ST.prod(l, r+1) vi, vc = v>>BASE, v&MASK print(vc, vi) flag = False else: m = q[1] L = m if flag: print("Not Found!")