結果
問題 | No.2942 Sigma Music Game Level Problem |
ユーザー | PNJ |
提出日時 | 2024-10-18 22:23:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,060 ms / 6,000 ms |
コード長 | 2,471 bytes |
コンパイル時間 | 425 ms |
コンパイル使用メモリ | 82,312 KB |
実行使用メモリ | 248,088 KB |
最終ジャッジ日時 | 2024-11-15 18:39:08 |
合計ジャッジ時間 | 30,355 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
65,920 KB |
testcase_01 | AC | 47 ms
66,176 KB |
testcase_02 | AC | 48 ms
66,304 KB |
testcase_03 | AC | 46 ms
65,920 KB |
testcase_04 | AC | 47 ms
66,048 KB |
testcase_05 | AC | 51 ms
65,920 KB |
testcase_06 | AC | 51 ms
66,176 KB |
testcase_07 | AC | 64 ms
70,144 KB |
testcase_08 | AC | 106 ms
84,096 KB |
testcase_09 | AC | 87 ms
80,128 KB |
testcase_10 | AC | 82 ms
77,440 KB |
testcase_11 | AC | 1,238 ms
193,036 KB |
testcase_12 | AC | 2,608 ms
186,064 KB |
testcase_13 | AC | 2,585 ms
122,708 KB |
testcase_14 | AC | 1,324 ms
213,796 KB |
testcase_15 | AC | 910 ms
203,172 KB |
testcase_16 | AC | 2,376 ms
107,844 KB |
testcase_17 | AC | 625 ms
122,096 KB |
testcase_18 | AC | 1,804 ms
130,524 KB |
testcase_19 | AC | 3,060 ms
140,728 KB |
testcase_20 | AC | 874 ms
179,560 KB |
testcase_21 | AC | 2,186 ms
247,960 KB |
testcase_22 | AC | 2,365 ms
248,088 KB |
testcase_23 | AC | 1,145 ms
114,432 KB |
testcase_24 | AC | 53 ms
65,792 KB |
testcase_25 | AC | 53 ms
65,920 KB |
testcase_26 | AC | 2,217 ms
212,688 KB |
ソースコード
def add(x,y): return x + y class segtree(): def __init__(self,n,op,e): self.n = n self.size = 1 << ((n - 1).bit_length()) self.e = e self.seg = [e for i in range(self.size << 1)] self.op = op def set(self,i,x): j = i + self.size self.seg[j] = x j >>= 1 while j: self.seg[j] = self.op(self.seg[j << 1],self.seg[(j << 1) ^ 1]) j >>= 1 return 0 def add(self,i,x): self.set(i,self.get(i) + x) return def set_array(self,A): for i in range(self.n): self.set(i,A[i]) return def get(self,i): return self.seg[i + self.size] def prod(self,l,r): sml = self.e smr = self.e ll = l + self.size rr = r + self.size while ll < rr: if ll & 1: sml = self.op(sml,self.seg[ll]) ll += 1 if rr & 1: smr = self.op(smr,self.seg[rr-1]) rr -= 1 ll >>= 1 rr >>= 1 return self.op(sml,smr) def max_right(self,l,f): if l == self.n: return self.n ll = l + self.size sm = self.e while True: while ll % 2 == 0: ll >>= 1 if not(f(self.op(sm,self.seg[ll]))): while ll < self.size: ll <<= 1 if f(self.op(sm,self.seg[ll])): sm = self.op(sm,self.seg[ll]) ll += 1 return ll - self.size sm = self.op(sm,self.seg[ll]) ll += 1 if (ll & -ll) == ll: break return self.n def min_left(self,r,f): if r == 0: return 0 rr = r + self.size sm = self.e while True: rr -= 1 while (rr > 1 and (rr % 2)): rr >>= 1 if not(f(self.op(self.seg[rr],sm))): while (rr < self.size): rr = (rr << 1) + 1 if self.op(sm,self.seg[rr]): sm = self.op(sm,self.seg[rr]) rr -= 1 return rr + 1 - self.size sm = self.op(sm,self.seg[rr]) if (rr & -rr) == rr: break return 0 N,Q,L = map(int,input().split()) A = list(map(int,input().split())) M = 200001 seg = segtree(M,add,0) segg = segtree(M,add,0) for a in A: seg.set(a,seg.get(a) + 1) segg.set(a,segg.get(a) + a) f = 1 for _ in range(Q): q = list(map(int,input().split())) if q[0] == 1: l = q[1] seg.set(l,seg.get(l) + 1) segg.set(l,segg.get(l) + l) elif q[0] == 2: f = 0 l,r = q[1],q[2] print(seg.prod(l,r + 1),segg.prod(l,r + 1)) else: m = q[1] if f: print('Not Found!')