結果

問題 No.865 24時間降水量
ユーザー roarisroaris
提出日時 2019-08-16 23:12:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,097 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 11,956 KB
実行使用メモリ 29,880 KB
最終ジャッジ日時 2023-10-24 04:42:46
合計ジャッジ時間 10,996 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
14,616 KB
testcase_01 AC 31 ms
10,184 KB
testcase_02 AC 30 ms
10,184 KB
testcase_03 AC 29 ms
10,184 KB
testcase_04 AC 30 ms
10,184 KB
testcase_05 AC 148 ms
10,340 KB
testcase_06 AC 147 ms
10,340 KB
testcase_07 AC 146 ms
10,340 KB
testcase_08 AC 147 ms
10,340 KB
testcase_09 AC 146 ms
10,340 KB
testcase_10 AC 1,159 ms
10,432 KB
testcase_11 AC 1,165 ms
10,432 KB
testcase_12 AC 1,161 ms
10,432 KB
testcase_13 AC 1,160 ms
10,436 KB
testcase_14 AC 1,155 ms
10,432 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def init(N):
    n_ = 1
    while n_ < N:
        n_ *= 2
        n = n_
    arr = [-10 ** 18] * (2*n - 1)
    return n, arr

def update(k, a):
    k += n - 1
    arr[k] = a
    while k > 0:
        k = (k - 1) // 2
        arr[k] = max(arr[2*k + 1], arr[2*k + 2])
        
def query_sub(a, b, k, l, r):
    if r <= a or b <= l:
        return -10 ** 18
        
    if a <= l and r <= b:
        return arr[k]
    else:
        vl = query_sub(a, b, 2*k + 1, l, (l+r) / 2)
        vr = query_sub(a, b, 2*k + 2, (l+r) / 2, r)
        return max(vl, vr)
    
def query(a, b):
    return query_sub(a, b, 0, 0, n)

N = int(input())
A = list(map(int, input().split()))
B = [sum(A[0:24])]

for i in range(1, N-23):
    B.append(B[-1] + A[i+23] - A[i-1])

M = len(B)
n, arr = init(N)

for i in range(M):
    update(i, B[i])

Q = int(input())

for _ in range(Q):
    Ti, Vi = map(int, input().split())
    Ti -= 1
    for i in range(max(Ti-23, 0), min(Ti+1, M)):
        update(i, B[i]-A[Ti]+Vi)
        B[i] = B[i] - A[Ti] + Vi
    A[Ti] = Vi
    print(query(0, M))
0