結果

問題 No.865 24時間降水量
ユーザー stngstng
提出日時 2022-07-24 21:18:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 883 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 111,168 KB
最終ジャッジ日時 2023-09-20 21:45:16
合計ジャッジ時間 8,325 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,284 KB
testcase_01 AC 72 ms
71,272 KB
testcase_02 AC 71 ms
71,504 KB
testcase_03 WA -
testcase_04 AC 72 ms
71,480 KB
testcase_05 AC 115 ms
77,540 KB
testcase_06 AC 114 ms
77,880 KB
testcase_07 AC 114 ms
77,612 KB
testcase_08 AC 114 ms
77,680 KB
testcase_09 AC 114 ms
77,664 KB
testcase_10 AC 187 ms
79,472 KB
testcase_11 AC 179 ms
79,796 KB
testcase_12 AC 177 ms
79,532 KB
testcase_13 AC 180 ms
79,756 KB
testcase_14 AC 177 ms
79,732 KB
testcase_15 AC 1,276 ms
111,168 KB
testcase_16 AC 1,279 ms
110,904 KB
testcase_17 AC 1,329 ms
110,968 KB
testcase_18 AC 71 ms
71,500 KB
testcase_19 AC 71 ms
71,328 KB
testcase_20 AC 72 ms
71,320 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-24):
    tmp = ki.sum(i+1+24)-ki.sum(i+1)
    ans = max(ans,tmp)

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