結果

問題 No.1000 Point Add and Array Add
コンテスト
ユーザー ああ
提出日時 2026-05-12 01:23:10
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 560 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 464 ms
コンパイル使用メモリ 85,212 KB
実行使用メモリ 116,432 KB
最終ジャッジ日時 2026-05-12 01:23:23
合計ジャッジ時間 10,566 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def aa(s,v):
    d=1
    while s<len(fen):
        if s&d:
            fen[s]+=v
            s+=d
        d<<=1
def bb(s):
    res,d=0,1
    while s:
        if s&d:
            res+=fen[s]
            s-=d
        d<<=1
    return res

n,q=map(int,input().split())
fen=[0]*(n+2)
ans=[0]*n
x=list(map(int,input().split()))
for i in range(q):
    a,b,c=input().split()
    b=int(b);c=int(c)
    if a=="A":
        x[b-1]+=c
        ans[b-1]-=bb(b)*c
    else:
        aa(b,1);aa(c+1,-1)
for i in range(n):
    ans[i]+=bb(i+1)*x[i]
print(" ".join(map(str,ans)))
0