結果

問題 No.865 24時間降水量
ユーザー stngstng
提出日時 2022-07-24 21:25:03
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 112,504 KB
最終ジャッジ日時 2023-09-20 21:53:12
合計ジャッジ時間 7,516 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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