結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー 👑 colognecologne
提出日時 2023-08-05 13:01:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 450 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 91,832 KB
最終ジャッジ日時 2024-04-23 10:14:25
合計ジャッジ時間 6,735 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,968 KB
testcase_01 AC 33 ms
52,096 KB
testcase_02 AC 40 ms
54,912 KB
testcase_03 AC 35 ms
52,992 KB
testcase_04 AC 45 ms
61,056 KB
testcase_05 AC 46 ms
61,440 KB
testcase_06 AC 44 ms
61,568 KB
testcase_07 AC 104 ms
88,304 KB
testcase_08 AC 71 ms
81,792 KB
testcase_09 AC 93 ms
88,300 KB
testcase_10 AC 76 ms
76,164 KB
testcase_11 AC 88 ms
83,704 KB
testcase_12 AC 103 ms
91,776 KB
testcase_13 AC 93 ms
89,600 KB
testcase_14 AC 88 ms
84,776 KB
testcase_15 AC 109 ms
83,720 KB
testcase_16 AC 107 ms
78,192 KB
testcase_17 AC 123 ms
91,604 KB
testcase_18 AC 123 ms
91,264 KB
testcase_19 AC 120 ms
91,648 KB
testcase_20 AC 123 ms
91,648 KB
testcase_21 AC 122 ms
91,472 KB
testcase_22 AC 127 ms
91,832 KB
testcase_23 AC 127 ms
91,520 KB
testcase_24 AC 130 ms
91,592 KB
testcase_25 AC 125 ms
91,264 KB
testcase_26 AC 131 ms
91,776 KB
testcase_27 AC 115 ms
90,948 KB
testcase_28 AC 121 ms
90,932 KB
testcase_29 AC 95 ms
76,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())
    *A, = map(int, input().split())
    z = sum(i**2 for i in A)
    Q = int(input())
    for i in range(Q):
        c, k, d = map(int, input().split())
        c -= 1
        d -= 1
        z -= A[c]**2 + A[d]**2
        A[c] -= k
        A[d] += k
        z += A[c]**2 + A[d]**2
        print(z)


if __name__ == '__main__':
    main()
0