結果

問題 No.865 24時間降水量
ユーザー stngstng
提出日時 2022-07-24 21:25:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,058 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 110,428 KB
最終ジャッジ日時 2024-07-06 16:40:59
合計ジャッジ時間 5,929 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,352 KB
testcase_01 AC 32 ms
52,224 KB
testcase_02 AC 33 ms
52,864 KB
testcase_03 AC 35 ms
52,352 KB
testcase_04 AC 32 ms
52,608 KB
testcase_05 AC 79 ms
76,544 KB
testcase_06 AC 79 ms
76,416 KB
testcase_07 AC 78 ms
76,416 KB
testcase_08 AC 79 ms
76,868 KB
testcase_09 AC 79 ms
76,420 KB
testcase_10 AC 126 ms
78,068 KB
testcase_11 AC 132 ms
78,184 KB
testcase_12 AC 126 ms
78,124 KB
testcase_13 AC 128 ms
77,696 KB
testcase_14 AC 126 ms
77,952 KB
testcase_15 AC 1,018 ms
110,428 KB
testcase_16 AC 1,030 ms
110,300 KB
testcase_17 AC 1,058 ms
110,396 KB
testcase_18 AC 36 ms
52,224 KB
testcase_19 AC 36 ms
52,224 KB
testcase_20 AC 35 ms
52,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
tv = [[int(i) for i in input().split()] for j in range(q)]

class Bit:
    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

ki = Bit(n+1)
for i in range(n):
    ki.add(i+1,a[i])

ans = 0
for i in range(n-23):
    #print(i,i+1+24)
    tmp = ki.sum(i+24)-ki.sum(i)
    #print(tmp)
    ans = max(ans,tmp)
#exit()
for i in range(q):
    t,v = tv[i]
    ki.add(t,v - (ki.sum(t)-ki.sum(t-1)))
    for j in range(24):
        if t-24+j < 0:
            continue
        if t+j > n:
            continue
        tmp = ki.sum(t+j)-ki.sum(t-24+j)
        ans = max(ans,tmp)
    print(ans)
0