結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-05-19 21:25:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 90,280 KB
最終ジャッジ日時 2024-05-10 05:08:46
合計ジャッジ時間 5,802 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,224 KB
testcase_01 AC 39 ms
51,968 KB
testcase_02 AC 44 ms
55,040 KB
testcase_03 AC 40 ms
52,608 KB
testcase_04 AC 50 ms
60,800 KB
testcase_05 AC 50 ms
61,440 KB
testcase_06 AC 49 ms
61,312 KB
testcase_07 AC 109 ms
86,140 KB
testcase_08 AC 78 ms
81,408 KB
testcase_09 AC 95 ms
86,400 KB
testcase_10 AC 83 ms
79,232 KB
testcase_11 AC 101 ms
82,572 KB
testcase_12 AC 116 ms
89,824 KB
testcase_13 AC 96 ms
88,064 KB
testcase_14 AC 88 ms
83,456 KB
testcase_15 AC 116 ms
83,680 KB
testcase_16 AC 112 ms
84,320 KB
testcase_17 AC 130 ms
89,728 KB
testcase_18 AC 131 ms
90,104 KB
testcase_19 AC 125 ms
89,612 KB
testcase_20 AC 130 ms
89,984 KB
testcase_21 AC 126 ms
89,948 KB
testcase_22 AC 130 ms
90,280 KB
testcase_23 AC 129 ms
90,252 KB
testcase_24 AC 129 ms
89,600 KB
testcase_25 AC 132 ms
89,948 KB
testcase_26 AC 132 ms
89,880 KB
testcase_27 AC 124 ms
89,344 KB
testcase_28 AC 128 ms
89,092 KB
testcase_29 AC 110 ms
82,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

"""

import sys
from sys import stdin

N,M = map(int,stdin.readline().split())

A = list(map(int,stdin.readline().split()))
ans = sum( [i**2 for i in A] )

Q = int(stdin.readline())
ANS = []

for i in range(Q):

    C,K,D = map(int,stdin.readline().split())
    C -= 1
    D -= 1

    ans -= A[C] ** 2
    ans -= A[D] ** 2

    A[C] -= K
    A[D] += K

    ans += A[C] ** 2
    ans += A[D] ** 2

    ANS.append(ans)

print (*ANS,sep="\n")
0