結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー FromBooskaFromBooska
提出日時 2023-05-19 21:32:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 405 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 91,036 KB
最終ジャッジ日時 2023-08-22 23:36:41
合計ジャッジ時間 11,693 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
70,656 KB
testcase_01 AC 82 ms
70,808 KB
testcase_02 AC 93 ms
74,924 KB
testcase_03 AC 82 ms
70,968 KB
testcase_04 AC 102 ms
75,764 KB
testcase_05 AC 105 ms
75,844 KB
testcase_06 AC 105 ms
75,844 KB
testcase_07 AC 294 ms
87,060 KB
testcase_08 AC 147 ms
82,024 KB
testcase_09 AC 210 ms
87,728 KB
testcase_10 AC 220 ms
78,004 KB
testcase_11 AC 238 ms
83,420 KB
testcase_12 AC 270 ms
90,444 KB
testcase_13 AC 216 ms
89,196 KB
testcase_14 AC 202 ms
84,420 KB
testcase_15 AC 334 ms
83,380 KB
testcase_16 AC 351 ms
79,252 KB
testcase_17 AC 405 ms
90,784 KB
testcase_18 AC 387 ms
90,872 KB
testcase_19 AC 386 ms
90,624 KB
testcase_20 AC 394 ms
90,628 KB
testcase_21 AC 384 ms
91,036 KB
testcase_22 AC 391 ms
91,016 KB
testcase_23 AC 390 ms
90,796 KB
testcase_24 AC 391 ms
90,780 KB
testcase_25 AC 385 ms
90,812 KB
testcase_26 AC 386 ms
90,748 KB
testcase_27 AC 366 ms
90,408 KB
testcase_28 AC 390 ms
89,800 KB
testcase_29 AC 360 ms
77,920 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