結果
| 問題 |
No.1000 Point Add and Array Add
|
| コンテスト | |
| ユーザー |
qqqq
|
| 提出日時 | 2020-03-26 19:02:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 349 ms / 2,000 ms |
| コード長 | 974 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 82,764 KB |
| 実行使用メモリ | 128,196 KB |
| 最終ジャッジ日時 | 2025-01-02 02:57:39 |
| 合計ジャッジ時間 | 6,929 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
class Binary_Indexed_Tree_RAQ():
def __init__(self, n):
self.data = [0]*(n+1)
self.n = n+1
def __add(self, ind, num):
while(ind <= self.n):
self.data[ind - 1] += num
ind += ind & -ind
# [s, t]
def range_add(self, s, t, x):
s += 1
t += 1
self.__add(s,x)
self.__add(t+1,-x)
# [0, i]
def query(self, i):
i += 1
ret = 0
while(i > 0):
ret += self.data[i-1]
i -= i & -i
return ret
n,q = map(int, input().split())
a = list(map(int, input().split()))
cxy = [input().split() for i in range(q)]
b = [0]*n
BIT = Binary_Indexed_Tree_RAQ(n)
for c,x,y in reversed(cxy):
x,y = int(x)-1, int(y)
if c == "A":
b[x] += BIT.query(x)*y
else:
BIT.range_add(x, y-1, 1)
for i in range(n):
b[i] += BIT.query(i)*a[i]
print(*b)
qqqq