結果
| 問題 |
No.1000 Point Add and Array Add
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-24 23:48:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 391 ms / 2,000 ms |
| コード長 | 776 bytes |
| コンパイル時間 | 273 ms |
| コンパイル使用メモリ | 82,280 KB |
| 実行使用メモリ | 152,124 KB |
| 最終ジャッジ日時 | 2024-06-25 23:03:31 |
| 合計ジャッジ時間 | 7,058 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
import sys
input = sys.stdin.readline
class BIT:
def __init__(self, n):
self.n = n
self.bit = [0]*(n+1)
def add(self, i, x):
i += 1
while i<=self.n:
self.bit[i] += x
i += i&(-i)
def acc(self, i):
s = 0
while i>0:
s += self.bit[i]
i -= i&(-i)
return s
N, Q = map(int, input().split())
A = list(map(int, input().split()))
cxy = [tuple(input().split()) for _ in range(Q)]
ans = [0]*N
bit = BIT(N)
for c, x, y in cxy[::-1]:
x, y = int(x), int(y)
if c=='A':
ans[x-1] += y*bit.acc(x)
else:
bit.add(x-1, 1)
bit.add(y, -1)
for i in range(N):
ans[i] += A[i]*bit.acc(i+1)
print(*ans)