結果

問題 No.1000 Point Add and Array Add
ユーザー hedwig100hedwig100
提出日時 2020-04-15 14:55:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,446 ms / 2,000 ms
コード長 1,207 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 44,836 KB
最終ジャッジ日時 2024-04-09 18:40:37
合計ジャッジ時間 12,311 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 30 ms
10,880 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 30 ms
10,880 KB
testcase_08 AC 31 ms
10,880 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 31 ms
10,880 KB
testcase_12 AC 37 ms
11,136 KB
testcase_13 AC 36 ms
10,880 KB
testcase_14 AC 41 ms
11,136 KB
testcase_15 AC 37 ms
11,136 KB
testcase_16 AC 884 ms
38,384 KB
testcase_17 AC 843 ms
27,100 KB
testcase_18 AC 1,306 ms
43,220 KB
testcase_19 AC 1,303 ms
43,224 KB
testcase_20 AC 906 ms
33,152 KB
testcase_21 AC 1,432 ms
44,836 KB
testcase_22 AC 1,112 ms
42,456 KB
testcase_23 AC 1,446 ms
44,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10 ** 7
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from bisect import bisect_left

class BinaryIndexedTree():

    def __init__(self,init_val):
        self.bit = [0] + init_val
        self.n  = len(init_val)

    def sum(self,i):
        ret = 0
        while i > 0:
            ret += self.bit[i]
            i -= (i & -i)
        return ret
    
    def add(self,i,x):
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)


def main():
    n,q = map(int,input().split())
    a = list(map(int,input().split()))
    b = [0] * n
    cnt = [0] * n
    bit = BinaryIndexedTree([0] * n)

    for _ in range(q):
        t,x,y = map(str,input().split())
        x = int(x)
        y = int(y)
        if t == 'A':
            c = bit.sum(x)
            b[x - 1] -= c * y
            a[x - 1] += y
        else:
            cnt[x - 1] += 1
            bit.add(x,1)
            if y < n:
                cnt[y] -= 1
                bit.add(y + 1,-1)
    
    b[0] += cnt[0] * a[0]
    for i in range(1,n):
        cnt[i] += cnt[i - 1]
        b[i] += cnt[i] * a[i]

    print(*b)

if __name__ == '__main__':
    main()
0