結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-05-19 21:25:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 974 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 90,740 KB
最終ジャッジ日時 2023-08-22 23:30:24
合計ジャッジ時間 7,331 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,384 KB
testcase_01 AC 66 ms
71,136 KB
testcase_02 AC 71 ms
71,132 KB
testcase_03 AC 67 ms
71,332 KB
testcase_04 AC 80 ms
75,328 KB
testcase_05 AC 75 ms
75,076 KB
testcase_06 AC 77 ms
75,524 KB
testcase_07 AC 129 ms
87,348 KB
testcase_08 AC 100 ms
82,180 KB
testcase_09 AC 116 ms
87,328 KB
testcase_10 AC 105 ms
81,016 KB
testcase_11 AC 113 ms
83,348 KB
testcase_12 AC 123 ms
90,344 KB
testcase_13 AC 113 ms
88,784 KB
testcase_14 AC 107 ms
84,664 KB
testcase_15 AC 133 ms
84,188 KB
testcase_16 AC 127 ms
85,304 KB
testcase_17 AC 140 ms
90,740 KB
testcase_18 AC 147 ms
90,480 KB
testcase_19 AC 151 ms
90,672 KB
testcase_20 AC 146 ms
90,440 KB
testcase_21 AC 145 ms
90,432 KB
testcase_22 AC 144 ms
90,492 KB
testcase_23 AC 143 ms
90,728 KB
testcase_24 AC 143 ms
90,488 KB
testcase_25 AC 148 ms
90,668 KB
testcase_26 AC 144 ms
90,672 KB
testcase_27 AC 135 ms
90,108 KB
testcase_28 AC 143 ms
90,084 KB
testcase_29 AC 127 ms
84,120 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