結果
問題 | No.1000 Point Add and Array Add |
ユーザー | H3PO4 |
提出日時 | 2021-08-21 19:08:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 369 ms / 2,000 ms |
コード長 | 894 bytes |
コンパイル時間 | 350 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 105,068 KB |
最終ジャッジ日時 | 2024-04-23 09:49:44 |
合計ジャッジ時間 | 6,341 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
51,712 KB |
testcase_01 | AC | 42 ms
52,352 KB |
testcase_02 | AC | 40 ms
52,096 KB |
testcase_03 | AC | 41 ms
51,840 KB |
testcase_04 | AC | 40 ms
52,224 KB |
testcase_05 | AC | 40 ms
52,096 KB |
testcase_06 | AC | 42 ms
52,068 KB |
testcase_07 | AC | 40 ms
51,840 KB |
testcase_08 | AC | 42 ms
51,712 KB |
testcase_09 | AC | 41 ms
52,352 KB |
testcase_10 | AC | 40 ms
52,352 KB |
testcase_11 | AC | 41 ms
52,096 KB |
testcase_12 | AC | 71 ms
70,400 KB |
testcase_13 | AC | 71 ms
70,400 KB |
testcase_14 | AC | 87 ms
76,792 KB |
testcase_15 | AC | 76 ms
72,064 KB |
testcase_16 | AC | 270 ms
105,068 KB |
testcase_17 | AC | 235 ms
91,816 KB |
testcase_18 | AC | 363 ms
103,540 KB |
testcase_19 | AC | 349 ms
103,108 KB |
testcase_20 | AC | 365 ms
102,580 KB |
testcase_21 | AC | 294 ms
102,960 KB |
testcase_22 | AC | 369 ms
103,492 KB |
testcase_23 | AC | 304 ms
102,588 KB |
ソースコード
import sys input = sys.stdin.readline N, Q = map(int, input().split()) A = list(map(int, input().split())) class Bit: """1-indexed""" def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i bit = Bit(N + 1) ans = [0] * N for _ in range(Q): c, x, y = input().split() x, y = int(x), int(y) if c == 'A': n = bit.sum(x) ans[x - 1] += n * A[x - 1] bit.add(x, -n) bit.add(x + 1, n) A[x - 1] += y else: # assert c == 'B' bit.add(x, 1) bit.add(y + 1, -1) for x in range(1, N + 1): n = bit.sum(x) ans[x - 1] += n * A[x - 1] print(*ans)