結果
問題 | No.2942 Sigma Music Game Level Problem |
ユーザー | hirayuu_yc |
提出日時 | 2024-10-05 21:26:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,548 ms / 6,000 ms |
コード長 | 1,040 bytes |
コンパイル時間 | 506 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 228,512 KB |
最終ジャッジ日時 | 2024-10-06 10:50:14 |
合計ジャッジ時間 | 25,511 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 66 ms
71,424 KB |
testcase_01 | AC | 66 ms
71,552 KB |
testcase_02 | AC | 66 ms
71,808 KB |
testcase_03 | AC | 67 ms
71,296 KB |
testcase_04 | AC | 66 ms
72,064 KB |
testcase_05 | AC | 65 ms
71,296 KB |
testcase_06 | AC | 67 ms
71,808 KB |
testcase_07 | AC | 72 ms
74,496 KB |
testcase_08 | AC | 104 ms
82,688 KB |
testcase_09 | AC | 87 ms
79,232 KB |
testcase_10 | AC | 83 ms
78,592 KB |
testcase_11 | AC | 982 ms
168,912 KB |
testcase_12 | AC | 2,117 ms
210,688 KB |
testcase_13 | AC | 2,184 ms
123,836 KB |
testcase_14 | AC | 1,055 ms
199,264 KB |
testcase_15 | AC | 718 ms
228,512 KB |
testcase_16 | AC | 2,011 ms
104,184 KB |
testcase_17 | AC | 531 ms
140,340 KB |
testcase_18 | AC | 1,492 ms
146,156 KB |
testcase_19 | AC | 2,548 ms
146,872 KB |
testcase_20 | AC | 672 ms
157,468 KB |
testcase_21 | AC | 1,585 ms
217,400 KB |
testcase_22 | AC | 1,475 ms
217,548 KB |
testcase_23 | AC | 911 ms
113,832 KB |
testcase_24 | AC | 68 ms
71,312 KB |
testcase_25 | AC | 66 ms
71,724 KB |
testcase_26 | AC | 1,962 ms
220,040 KB |
ソースコード
import typing class FenwickTree: '''Reference: https://en.wikipedia.org/wiki/Fenwick_tree''' def __init__(self, n: int = 0) -> None: self._n = n self.data = [0] * n def add(self, p: int, x: typing.Any) -> None: assert 0 <= p < self._n p += 1 while p <= self._n: self.data[p - 1] += x p += p & -p def sum(self, left: int, right: int) -> typing.Any: assert 0 <= left <= right <= self._n return self._sum(right) - self._sum(left) def _sum(self, r: int) -> typing.Any: s = 0 while r > 0: s += self.data[r - 1] r -= r & -r return s N,Q,L=map(int,input().split()) A=list(map(int,input().split())) f1=FenwickTree(300000) f2=FenwickTree(300000) for i in A: f1.add(i,1) f2.add(i,i) flg=True for i in range(Q): t,*q=list(map(int,input().split())) if t==1: l=q[0] f1.add(l,1) f2.add(l,l) if t==2: flg=False l,r=q print(f1.sum(l,r+1),f2.sum(l,r+1)) if flg: print("Not Found!")