結果

問題 No.1000 Point Add and Array Add
ユーザー brthyyjpbrthyyjp
提出日時 2020-03-20 12:52:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 507 ms / 2,000 ms
コード長 680 bytes
コンパイル時間 1,506 ms
コンパイル使用メモリ 86,732 KB
実行使用メモリ 140,492 KB
最終ジャッジ日時 2023-08-20 21:37:39
合計ジャッジ時間 7,915 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,384 KB
testcase_01 AC 74 ms
71,116 KB
testcase_02 AC 72 ms
71,212 KB
testcase_03 AC 73 ms
71,312 KB
testcase_04 AC 73 ms
71,452 KB
testcase_05 AC 73 ms
71,324 KB
testcase_06 AC 73 ms
71,220 KB
testcase_07 AC 73 ms
71,252 KB
testcase_08 AC 74 ms
71,200 KB
testcase_09 AC 73 ms
71,108 KB
testcase_10 AC 73 ms
71,080 KB
testcase_11 AC 72 ms
71,384 KB
testcase_12 AC 121 ms
77,828 KB
testcase_13 AC 116 ms
78,336 KB
testcase_14 AC 124 ms
78,444 KB
testcase_15 AC 123 ms
78,016 KB
testcase_16 AC 393 ms
122,500 KB
testcase_17 AC 366 ms
112,884 KB
testcase_18 AC 506 ms
140,408 KB
testcase_19 AC 507 ms
140,300 KB
testcase_20 AC 473 ms
137,232 KB
testcase_21 AC 477 ms
140,488 KB
testcase_22 AC 487 ms
140,492 KB
testcase_23 AC 501 ms
140,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, q = map(int, input().split())
A = list(map(int, input().split()))

bit = [0]*(n+1)

def bit_query(i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i & (-i)
    return res

def bit_update(i, x):
    while i <= n:
        bit[i] += x
        i += i & (-i)

L = [0]*q
for i in range(q):
    query = list(map(str, input().split()))
    L[i] = query
L.reverse()

B = [0]*n
for i in range(q):
    c, x, y = L[i]
    if c == 'B':
        x = int(x)
        y = int(y)
        bit_update(x, 1)
        bit_update(y+1, -1)
    else:
        x = int(x)-1
        y = int(y)
        B[x] += y*bit_query(x+1)
for i in range(n):
    B[i] += A[i]*bit_query(i+1)
print(*B)
0