結果
問題 |
No.789 範囲の合計
|
ユーザー |
![]() |
提出日時 | 2021-03-23 23:43:30 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 760 bytes |
コンパイル時間 | 83 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 60,940 KB |
最終ジャッジ日時 | 2024-11-26 07:11:56 |
合計ジャッジ時間 | 11,031 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 TLE * 2 |
ソースコード
class DynamicBIT: def __init__(self, MAX=10**9): self.data = dict() self.MAX = MAX def add(self, i, x): i += 1 while i <= self.MAX: if i not in self.data: self.data[i] = 0 self.data[i] += x i += i & -i def acc(self, i): res = 0 while i: if i in self.data: res += self.data[i] i -= i & -i return res def prod(self, l, r): return self.acc(r) - self.acc(l) import sys input = sys.stdin.readline q = int(input()) B = DynamicBIT(10**9+1) ans = 0 for _ in range(q): t, p, x = map(int, input().split()) if t == 0: B.add(p, x) else: ans += B.prod(p, x+1) print(ans)