結果
問題 | No.865 24時間降水量 |
ユーザー |
![]() |
提出日時 | 2019-08-16 22:52:59 |
言語 | PyPy3 (7.3.8) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,295 bytes |
コンパイル時間 | 623 ms |
使用メモリ | 84,504 KB |
最終ジャッジ日時 | 2022-11-22 10:21:20 |
合計ジャッジ時間 | 12,122 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 81 ms
75,804 KB |
testcase_01 | AC | 78 ms
75,676 KB |
testcase_02 | AC | 79 ms
75,584 KB |
testcase_03 | AC | 76 ms
75,728 KB |
testcase_04 | AC | 74 ms
75,424 KB |
testcase_05 | AC | 156 ms
82,576 KB |
testcase_06 | AC | 158 ms
83,024 KB |
testcase_07 | AC | 158 ms
82,476 KB |
testcase_08 | AC | 163 ms
83,272 KB |
testcase_09 | AC | 149 ms
82,900 KB |
testcase_10 | AC | 249 ms
84,068 KB |
testcase_11 | AC | 236 ms
83,540 KB |
testcase_12 | AC | 241 ms
84,504 KB |
testcase_13 | AC | 256 ms
83,952 KB |
testcase_14 | AC | 246 ms
84,192 KB |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | AC | 75 ms
75,468 KB |
testcase_19 | AC | 76 ms
75,816 KB |
testcase_20 | AC | 76 ms
75,464 KB |
ソースコード
import sys input = sys.stdin.readline class SegmentTree: def __init__(self, N): n_ = 1 while n_ < N: n_ *= 2 self.n = n_ self.arr = [-10 ** 18] * (2*self.n - 1) def update(self, k, a): k += self.n - 1 self.arr[k] = a while k > 0: k = (k - 1) // 2 self.arr[k] = max(self.arr[2*k + 1], self.arr[2*k + 2]) def query_sub(self, a, b, k, l, r): if r <= a or b <= l: return -10 ** 18 if a <= l and r <= b: return self.arr[k] else: vl = self.query_sub(a, b, 2*k + 1, l, (l+r) / 2) vr = self.query_sub(a, b, 2*k + 2, (l+r) / 2, r) return max(vl, vr) def query(self, a, b): return self.query_sub(a, b, 0, 0, self.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) st = SegmentTree(M) for i in range(M): st.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)): st.update(i, B[i]-A[Ti]+Vi) B[i] = B[i] - A[Ti] + Vi A[Ti] = Vi print(st.query(0, M))