結果
| 問題 |
No.1000 Point Add and Array Add
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-02-28 21:49:28 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 896 bytes |
| コンパイル時間 | 112 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 110,324 KB |
| 最終ジャッジ日時 | 2024-10-13 17:14:46 |
| 合計ジャッジ時間 | 16,819 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 TLE * 4 |
ソースコード
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)
titia