結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,468 KB
testcase_01 AC 73 ms
71,268 KB
testcase_02 AC 80 ms
71,268 KB
testcase_03 AC 73 ms
71,340 KB
testcase_04 AC 87 ms
75,136 KB
testcase_05 AC 84 ms
75,460 KB
testcase_06 AC 84 ms
75,048 KB
testcase_07 AC 144 ms
87,084 KB
testcase_08 AC 107 ms
81,704 KB
testcase_09 AC 123 ms
87,288 KB
testcase_10 AC 111 ms
77,500 KB
testcase_11 AC 121 ms
83,300 KB
testcase_12 AC 136 ms
90,020 KB
testcase_13 AC 126 ms
88,612 KB
testcase_14 AC 119 ms
84,852 KB
testcase_15 AC 141 ms
83,976 KB
testcase_16 AC 136 ms
78,988 KB
testcase_17 AC 156 ms
90,240 KB
testcase_18 AC 156 ms
90,384 KB
testcase_19 AC 156 ms
90,364 KB
testcase_20 AC 155 ms
90,300 KB
testcase_21 AC 160 ms
90,312 KB
testcase_22 AC 157 ms
90,252 KB
testcase_23 AC 157 ms
90,352 KB
testcase_24 AC 157 ms
90,092 KB
testcase_25 AC 154 ms
90,008 KB
testcase_26 AC 158 ms
90,532 KB
testcase_27 AC 146 ms
89,680 KB
testcase_28 AC 158 ms
89,708 KB
testcase_29 AC 132 ms
77,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

n, m = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(m):
    ans += pow(A[i], 2)
q = int(input())
for _ in range(q):
    c, k, d = map(int, input().split())
    c -= 1
    d -= 1
    ans -= pow(A[c], 2) + pow(A[d], 2)
    A[c] -= k
    A[d] += k
    ans += pow(A[c], 2) + pow(A[d], 2)
    print(ans)
0