結果
問題 | No.865 24時間降水量 |
ユーザー | rlangevin |
提出日時 | 2023-11-07 20:26:13 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,224 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 81,844 KB |
実行使用メモリ | 107,916 KB |
最終ジャッジ日時 | 2023-11-07 20:26:25 |
合計ジャッジ時間 | 10,427 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
59,512 KB |
testcase_01 | AC | 39 ms
59,000 KB |
testcase_02 | AC | 39 ms
59,000 KB |
testcase_03 | AC | 41 ms
59,000 KB |
testcase_04 | AC | 40 ms
59,000 KB |
testcase_05 | AC | 91 ms
76,172 KB |
testcase_06 | AC | 94 ms
76,188 KB |
testcase_07 | AC | 91 ms
76,044 KB |
testcase_08 | AC | 90 ms
76,176 KB |
testcase_09 | AC | 91 ms
76,296 KB |
testcase_10 | AC | 182 ms
77,056 KB |
testcase_11 | AC | 181 ms
76,804 KB |
testcase_12 | AC | 180 ms
76,948 KB |
testcase_13 | AC | 182 ms
76,948 KB |
testcase_14 | AC | 182 ms
77,204 KB |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | AC | 36 ms
53,460 KB |
testcase_19 | AC | 36 ms
53,460 KB |
testcase_20 | AC | 38 ms
59,000 KB |
ソースコード
import sys input = sys.stdin.readline class SegmentTree: def __init__(self, size, f=min, default=10 ** 18): self.size = 2**(size-1).bit_length() self.default = default self.dat = [default]*(self.size*2) self.f = f def update(self, i, x): i += self.size self.dat[i] = x while i > 0: i >>= 1 self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1]) def query(self, l, r): l += self.size r += self.size lres, rres = self.default, self.default while l < r: if l & 1: lres = self.f(lres, self.dat[l]) l += 1 if r & 1: r -= 1 rres = self.f(self.dat[r], rres) l >>= 1 r >>= 1 res = self.f(lres, rres) return res N = int(input()) A = list(map(int, input().split())) Seg = SegmentTree(N, max, 0) for i in range(N - 23): Seg.update(i, sum(A[i:i+24])) Q = int(input()) for _ in range(Q): T, V = map(int, input().split()) T -= 1 A[T] = V for i in range(max(0, T - 23), min(N - 23, T + 1)): Seg.update(i, sum(A[i:i+24])) print(Seg.query(0, N))