結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー dangodango
提出日時 2023-06-25 11:50:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 388 ms / 2,000 ms
コード長 346 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 91,352 KB
最終ジャッジ日時 2023-09-15 08:34:41
合計ジャッジ時間 12,945 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,496 KB
testcase_01 AC 71 ms
71,600 KB
testcase_02 AC 87 ms
75,480 KB
testcase_03 AC 73 ms
71,468 KB
testcase_04 AC 100 ms
76,612 KB
testcase_05 AC 96 ms
76,196 KB
testcase_06 AC 95 ms
76,048 KB
testcase_07 AC 277 ms
87,756 KB
testcase_08 AC 139 ms
82,624 KB
testcase_09 AC 206 ms
88,056 KB
testcase_10 AC 207 ms
78,560 KB
testcase_11 AC 221 ms
83,904 KB
testcase_12 AC 255 ms
91,032 KB
testcase_13 AC 206 ms
89,140 KB
testcase_14 AC 189 ms
84,992 KB
testcase_15 AC 320 ms
83,912 KB
testcase_16 AC 325 ms
79,976 KB
testcase_17 AC 370 ms
91,268 KB
testcase_18 AC 358 ms
91,288 KB
testcase_19 AC 359 ms
90,896 KB
testcase_20 AC 364 ms
91,248 KB
testcase_21 AC 366 ms
91,048 KB
testcase_22 AC 358 ms
91,220 KB
testcase_23 AC 367 ms
91,352 KB
testcase_24 AC 362 ms
91,236 KB
testcase_25 AC 360 ms
91,340 KB
testcase_26 AC 371 ms
90,940 KB
testcase_27 AC 337 ms
90,488 KB
testcase_28 AC 388 ms
90,756 KB
testcase_29 AC 325 ms
78,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = sum([i ** 2 for i in A])
for _ in range(int(input())):
    C, K, D = map(int, input().split())
    BC = A[C - 1]
    BD = A[D - 1]
    AC = BC - K
    AD = BD + K
    ans -= BC ** 2 + BD ** 2
    ans += AC ** 2 + AD ** 2
    A[C - 1] = AC
    A[D - 1] = AD
    print(ans)
0