結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,712 KB
testcase_01 AC 39 ms
52,096 KB
testcase_02 AC 59 ms
61,696 KB
testcase_03 AC 44 ms
52,992 KB
testcase_04 AC 70 ms
65,920 KB
testcase_05 AC 71 ms
66,432 KB
testcase_06 AC 72 ms
66,560 KB
testcase_07 AC 257 ms
86,912 KB
testcase_08 AC 120 ms
81,536 KB
testcase_09 AC 184 ms
86,656 KB
testcase_10 AC 190 ms
77,312 KB
testcase_11 AC 205 ms
83,332 KB
testcase_12 AC 238 ms
90,240 KB
testcase_13 AC 187 ms
88,064 KB
testcase_14 AC 173 ms
83,840 KB
testcase_15 AC 309 ms
82,844 KB
testcase_16 AC 313 ms
78,720 KB
testcase_17 AC 357 ms
90,368 KB
testcase_18 AC 345 ms
90,496 KB
testcase_19 AC 360 ms
90,368 KB
testcase_20 AC 358 ms
90,624 KB
testcase_21 AC 355 ms
90,112 KB
testcase_22 AC 348 ms
90,368 KB
testcase_23 AC 350 ms
90,112 KB
testcase_24 AC 353 ms
90,240 KB
testcase_25 AC 360 ms
90,240 KB
testcase_26 AC 348 ms
89,984 KB
testcase_27 AC 326 ms
89,088 KB
testcase_28 AC 356 ms
89,344 KB
testcase_29 AC 318 ms
76,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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