結果
問題 |
No.789 範囲の合計
|
ユーザー |
![]() |
提出日時 | 2025-03-29 20:55:27 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 740 bytes |
コンパイル時間 | 446 ms |
コンパイル使用メモリ | 82,576 KB |
実行使用メモリ | 210,172 KB |
最終ジャッジ日時 | 2025-03-29 20:55:36 |
合計ジャッジ時間 | 8,610 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 MLE * 8 |
ソースコード
class DynamicBIT: from collections import defaultdict def __init__(self, n): self.n = n + 1 self.d = self.defaultdict(int) def add(self, i, x): i += 1 while i <= self.n: self.d[i] += x i += i & -i def _sum(self, i): res = 0 while i > 0: res += self.d[i] i -= i & -i return res def sum(self, l, r): return self._sum(r) - self._sum(l) import sys input=sys.stdin.readline M=10**9 n=int(input()) bit=DynamicBIT(M) ans=0 for _ in range(n): t,*query=map(int,input().split()) if t==0: x,y=query bit.add(x,y) else: l,r=query ans+=bit.sum(l,r+1) print(ans)