結果
| 問題 |
No.865 24時間降水量
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:12:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 673 ms / 2,000 ms |
| コード長 | 1,124 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 82,588 KB |
| 実行使用メモリ | 118,672 KB |
| 最終ジャッジ日時 | 2025-03-20 21:14:10 |
| 合計ジャッジ時間 | 4,952 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
n = int(input())
A = list(map(int, input().split()))
window_size = 24
# Initialize the sums array
sums = []
if n >= window_size:
s_count = n - window_size + 1
current_sum = sum(A[:window_size])
sums.append(current_sum)
for s in range(1, s_count):
current_sum = current_sum - A[s - 1] + A[s + window_size - 1]
sums.append(current_sum)
current_max = max(sums) if sums else 0
Q = int(input())
for _ in range(Q):
T_j, V_j = map(int, input().split())
T = T_j - 1 # Convert to 0-based index
old_val = A[T]
new_val = V_j
delta = new_val - old_val
if delta == 0:
print(current_max)
continue
A[T] = new_val # Update the value in the array
s_start = max(0, T - window_size + 1)
s_end = min(T, n - window_size)
if s_start > s_end:
print(current_max)
continue
temp_max = 0
# Iterate over all affected windows
for s in range(s_start, s_end + 1):
sums[s] += delta
if sums[s] > temp_max:
temp_max = sums[s]
if temp_max > current_max:
current_max = temp_max
print(current_max)
lam6er