結果
問題 |
No.3164 [Chery 7th Tune B] La vie en rose
|
ユーザー |
|
提出日時 | 2025-08-11 11:23:12 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 555 bytes |
コンパイル時間 | 1,438 ms |
コンパイル使用メモリ | 82,024 KB |
実行使用メモリ | 77,472 KB |
最終ジャッジ日時 | 2025-08-11 11:23:21 |
合計ジャッジ時間 | 7,894 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 TLE * 1 -- * 28 |
ソースコード
from collections import deque n = int(input()) a = list(map(int, input().split())) q = int(input()) for _ in range(q): x, b = map(int, input().split()) x -= 1 visited = [False] * n queue = deque([x]) visited[x] = True total = 0 while queue: current = queue.popleft() total += a[current] for next in [current - 1, current + 1]: if 0 <= next < n and not visited[next] and a[next] > 0: visited[next] = True queue.append(next) print(total + b - a[x])