結果

問題 No.3164 [Chery 7th Tune B] La vie en rose
コンテスト
ユーザー M
提出日時 2025-08-11 11:12:09
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 591 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 229 ms
コンパイル使用メモリ 95,984 KB
実行使用メモリ 245,328 KB
最終ジャッジ日時 2026-07-13 22:44:21
合計ジャッジ時間 5,314 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 TLE * 1 -- * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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