結果

問題 No.2942 Sigma Music Game Level Problem
ユーザー hirayuu_ychirayuu_yc
提出日時 2024-10-05 21:25:13
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,039 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 82,032 KB
実行使用メモリ 228,320 KB
最終ジャッジ日時 2024-10-06 10:50:10
合計ジャッジ時間 27,873 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,808 KB
testcase_01 WA -
testcase_02 AC 65 ms
71,296 KB
testcase_03 WA -
testcase_04 AC 64 ms
71,424 KB
testcase_05 AC 64 ms
71,296 KB
testcase_06 AC 70 ms
71,296 KB
testcase_07 AC 68 ms
73,856 KB
testcase_08 AC 101 ms
82,560 KB
testcase_09 AC 84 ms
79,616 KB
testcase_10 AC 80 ms
78,336 KB
testcase_11 AC 1,071 ms
168,944 KB
testcase_12 AC 2,478 ms
210,520 KB
testcase_13 AC 2,467 ms
123,856 KB
testcase_14 AC 1,173 ms
198,972 KB
testcase_15 AC 792 ms
228,320 KB
testcase_16 AC 2,244 ms
104,304 KB
testcase_17 AC 564 ms
140,096 KB
testcase_18 AC 1,699 ms
146,532 KB
testcase_19 AC 2,813 ms
147,200 KB
testcase_20 AC 753 ms
157,104 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1,026 ms
113,872 KB
testcase_24 AC 63 ms
71,424 KB
testcase_25 AC 64 ms
71,680 KB
testcase_26 AC 2,195 ms
219,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 Find!")
0