結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,208 KB
testcase_01 AC 65 ms
70,892 KB
testcase_02 AC 86 ms
74,908 KB
testcase_03 AC 66 ms
71,324 KB
testcase_04 AC 88 ms
75,668 KB
testcase_05 AC 87 ms
75,884 KB
testcase_06 AC 87 ms
76,056 KB
testcase_07 AC 244 ms
86,832 KB
testcase_08 AC 123 ms
81,948 KB
testcase_09 AC 189 ms
87,540 KB
testcase_10 AC 185 ms
78,136 KB
testcase_11 AC 193 ms
83,200 KB
testcase_12 AC 239 ms
90,152 KB
testcase_13 AC 188 ms
88,652 KB
testcase_14 AC 179 ms
84,396 KB
testcase_15 AC 286 ms
83,044 KB
testcase_16 AC 293 ms
78,752 KB
testcase_17 AC 328 ms
90,360 KB
testcase_18 AC 329 ms
89,904 KB
testcase_19 AC 323 ms
90,124 KB
testcase_20 AC 338 ms
89,904 KB
testcase_21 AC 334 ms
90,272 KB
testcase_22 AC 335 ms
90,112 KB
testcase_23 AC 328 ms
90,068 KB
testcase_24 AC 334 ms
90,136 KB
testcase_25 AC 338 ms
90,376 KB
testcase_26 AC 332 ms
90,268 KB
testcase_27 AC 306 ms
89,584 KB
testcase_28 AC 327 ms
89,696 KB
testcase_29 AC 304 ms
78,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
A=list(map(int,input().split()))
power_now=0
for i in range(M):
    power_now+=A[i]**2
Q=int(input())
for _ in range(Q):
    c,k,d=map(int,input().split())
    c-=1
    d-=1
    a_c=A[c]
    a_d=A[d]
    power_now-=(a_c**2+a_d**2)
    A[d]+=k
    A[c]-=k
    a_c=A[c]
    a_d=A[d]
    power_now+=(a_c**2+a_d**2)
    print(power_now)
0