結果
問題 | No.865 24時間降水量 |
ユーザー | nadare |
提出日時 | 2019-08-16 22:43:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,230 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 82,308 KB |
実行使用メモリ | 119,676 KB |
最終ジャッジ日時 | 2024-09-22 19:06:11 |
合計ジャッジ時間 | 8,984 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,384 KB |
testcase_01 | AC | 38 ms
53,396 KB |
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 | TLE | - |
testcase_17 | WA | - |
testcase_18 | AC | 38 ms
53,548 KB |
testcase_19 | AC | 40 ms
54,192 KB |
testcase_20 | AC | 39 ms
53,260 KB |
ソースコード
# -*- coding: utf-8 -*- from math import sqrt def inpl(): return list(map(int, input().split())) class SegmentTree: def __init__(self, N, init_node=None): self.size = 2**int.bit_length(N) self.node = [0]*(2*self.size-1) if not init_node is None: for i in range(N): self.node[i+self.size-1] = init_node[i] for i in range(self.size-2, -1, -1): self.node[i] = max(self.node[2*i+1], self.node[2*i+2]) def add(self, x, val): x += self.size - 1 self.node[x] += val while x: x = (x-1)//2 self.node[x] = max(self.node[2*x+1], self.node[2*x+2]) class LazySegmentTree: def __init__(self, N, init_node=None): self.size = 2**int.bit_length(N) self.node = [0]*(2*self.size-1) if not init_node is None: for i in range(N): self.node[i+self.size-1] = init_node[i] for i in range(self.size-2, -1, -1): self.node[i] = max(self.node[2*i+1], self.node[2*i+2]) self.lazy = [0]*(2*self.size-1) def eval(self, k, l, r): if self.lazy[k]: self.node[k] += self.lazy[k] if r-l-1: self.lazy[2*k+1] += self.lazy[k] self.lazy[2*k+2] += self.lazy[k] self.lazy[k] = 0 def add(self, a, b, val, k=None, l=None, r=None): if k is None: k = 0 l = 0 r = self.size self.eval(k, l, r) if (b <= l) or (r <= a): return if (a<=l) and (r<=b): self.lazy[k] += val self.eval(k, l, r) else: self.add(a, b, val, 2*k+1, l, (l+r)//2) self.add(a, b, val, 2*k+2, (l+r)//2, r) self.node[k] = max(self.node[2*k+1], self.node[2*k+2]) N = int(input()) A = [0] * 23 + inpl() + [0]*23 s = sum(A[:24]) X = [0]*(N + 46) for i in range(24): X[i] = A[23]*1 s = A[23]*1 for i in range(24, N+46): s += A[i] - A[i-24] X[i] = s seg = LazySegmentTree(len(X), X) for _ in range(int(input())): t, v = inpl() t += 22 d = v - A[t] A[t] = v seg.add(t-23, t+24, d) print(seg.node[0])