結果

問題 No.789 範囲の合計
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-18 19:41:01
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 581 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 131,648 KB
最終ジャッジ日時 2023-10-21 08:14:04
合計ジャッジ時間 6,429 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,432 KB
testcase_01 AC 41 ms
53,432 KB
testcase_02 AC 490 ms
119,896 KB
testcase_03 AC 205 ms
75,796 KB
testcase_04 AC 562 ms
119,124 KB
testcase_05 AC 474 ms
111,220 KB
testcase_06 AC 473 ms
119,888 KB
testcase_07 AC 222 ms
75,776 KB
testcase_08 MLE -
testcase_09 AC 420 ms
119,124 KB
testcase_10 AC 408 ms
106,076 KB
testcase_11 MLE -
testcase_12 MLE -
testcase_13 AC 38 ms
53,436 KB
testcase_14 AC 37 ms
53,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

MAX = 10 ** 9 + 5
d = dict()


def _sum(i):
    res = 0
    while i > 0:
        res += d.get(i - 1, 0)
        i -= i & -i
    return res


def add(i, x):
    i += 1
    tmp = dict()
    while i < MAX:
        tmp[i - 1] = x + d.get(i - 1, 0)
        i += i & -i
    d.update(tmp)


def bitsum(l, r):
    return _sum(r) - _sum(l)



n = int(input())
ans = 0
for _ in range(n):
    k, x, y = map(int, input().split())
    if k == 0:
        add(x, y)
    else:
        ans += bitsum(x, y + 1)
print(ans)
0