結果

問題 No.1000 Point Add and Array Add
ユーザー titiatitia
提出日時 2020-02-28 21:49:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 896 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 110,324 KB
最終ジャッジ日時 2024-04-21 18:19:06
合計ジャッジ時間 17,153 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 26 ms
10,624 KB
testcase_04 AC 25 ms
10,880 KB
testcase_05 AC 25 ms
10,752 KB
testcase_06 AC 25 ms
10,752 KB
testcase_07 AC 25 ms
10,752 KB
testcase_08 AC 27 ms
10,624 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 27 ms
10,752 KB
testcase_11 AC 27 ms
10,624 KB
testcase_12 AC 37 ms
11,264 KB
testcase_13 AC 35 ms
11,136 KB
testcase_14 AC 44 ms
11,648 KB
testcase_15 AC 37 ms
11,392 KB
testcase_16 AC 1,395 ms
69,816 KB
testcase_17 AC 1,289 ms
64,700 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,907 ms
97,876 KB
testcase_21 AC 1,726 ms
68,128 KB
testcase_22 TLE -
testcase_23 AC 1,800 ms
73,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


LEN=N+5

BIT=[0]*(LEN+1)# 1-indexedなtree

def update(v,w):# index vにwを加える
    while v<=LEN:
        BIT[v]+=w
        v+=(v&(-v))# 自分を含む大きなノードへ. たとえばv=3→v=4

def getvalue(v):# [1,v]の区間の和を求める
    ANS=0
    while v!=0:
        ANS+=BIT[v]
        v-=(v&(-v))# 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ
    return ANS

from collections import defaultdict
check=defaultdict(list)

for c,x,y in Q:
    x=int(x)
    y=int(y)

    if c=="B":
        update(x,1)
        update(y+1,-1)

    else:
        check[x].append((getvalue(x),y))

ANS=[0]*N
for i in range(N):
    ANS[i]+=getvalue(i+1)*A[i]

#print(ANS)

for x in check:
    for c,y in check[x]:
        ANS[x-1]+=(getvalue(x)-c)*y

print(*ANS)
0