結果

問題 No.3164 [Chery 7th Tune B] La vie en rose
ユーザー Meso Meso
提出日時 2025-08-11 11:11:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 591 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 22,868 KB
最終ジャッジ日時 2025-08-11 11:11:43
合計ジャッジ時間 9,505 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 TLE * 1 -- * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import copy

n = int(input())
a = list(map(int, input().split()))
q = int(input())

for _ in range(q):
    x, b = map(int, input().split())
    x -= 1
    c = copy.copy(a)
    c[x] = b

    visited = [False] * n
    queue = deque([x])
    visited[x] = True
    total = 0

    while queue:
        current = queue.popleft()
        total += c[current]
   
        for next in [current - 1, current + 1]:
            if 0 <= next < n and not visited[next] and c[next] > 0:
                visited[next] = True
                queue.append(next)

    print(total)
0