結果

問題 No.789 範囲の合計
ユーザー titiatitia
提出日時 2019-02-09 01:02:57
言語 PyPy3
(7.3.13)
結果
MLE  
実行時間 -
コード長 637 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 141,148 KB
最終ジャッジ日時 2023-09-14 04:02:21
合計ジャッジ時間 3,432 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,548 KB
testcase_01 AC 63 ms
71,272 KB
testcase_02 MLE -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

n=int(input())
Q=[list(map(int,input().split())) for i in range(n)]

SET=set()
for x,a,b in Q:
    if x==0:
        SET.add(a)
    else:
        SET.add(a)
        SET.add(b)

DICT={x:i for i,x in enumerate(sorted(SET))}
N=len(DICT)

BIT=[0]*N

def update(v,w):#vにwを加える
    while v<N:
        BIT[v]+=w
        v+=(v&(-v))

def getvalue(v):#0~vの区間の和を求める
    ANS=0
    while v>0:
        ANS+=BIT[v]
        v-=(v&(-v))
    return ANS

ANS=0
for x,a,b in Q:
    if x==0:
        update(DICT[a],b)
    else:
        ANS+=getvalue(DICT[b])-getvalue(DICT[a]-1)

print(ANS)
0