結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー Kude
提出日時 2023-05-19 21:31:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 352 ms / 2,000 ms
コード長 305 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 89,856 KB
最終ジャッジ日時 2024-12-18 02:19:13
合計ジャッジ時間 9,570 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
h = list(map(int, input().split()))
now = sum(x * x for x in h)
for _ in range(int(input())):
    c, k, d = map(int, input().split())
    c -= 1
    d -= 1
    now -= h[c] * h[c] + h[d] * h[d]
    h[c] -= k
    h[d] += k
    now += h[c] * h[c] + h[d] * h[d]
    print(now)
0