結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー rlangevinrlangevin
提出日時 2023-05-19 21:23:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 381 bytes
コンパイル時間 1,338 ms
コンパイル使用メモリ 86,568 KB
実行使用メモリ 90,468 KB
最終ジャッジ日時 2023-08-22 23:25:37
合計ジャッジ時間 6,618 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,144 KB
testcase_01 AC 66 ms
71,348 KB
testcase_02 AC 71 ms
71,180 KB
testcase_03 AC 66 ms
70,928 KB
testcase_04 AC 83 ms
75,152 KB
testcase_05 AC 75 ms
75,376 KB
testcase_06 AC 75 ms
75,404 KB
testcase_07 AC 132 ms
87,320 KB
testcase_08 AC 95 ms
81,700 KB
testcase_09 AC 111 ms
87,324 KB
testcase_10 AC 102 ms
77,216 KB
testcase_11 AC 113 ms
83,072 KB
testcase_12 AC 136 ms
89,916 KB
testcase_13 AC 125 ms
88,344 KB
testcase_14 AC 105 ms
84,016 KB
testcase_15 AC 128 ms
82,896 KB
testcase_16 AC 126 ms
78,528 KB
testcase_17 AC 144 ms
90,404 KB
testcase_18 AC 146 ms
90,468 KB
testcase_19 AC 145 ms
90,272 KB
testcase_20 AC 139 ms
90,380 KB
testcase_21 AC 145 ms
90,396 KB
testcase_22 AC 150 ms
90,300 KB
testcase_23 AC 162 ms
90,244 KB
testcase_24 AC 146 ms
90,280 KB
testcase_25 AC 147 ms
90,284 KB
testcase_26 AC 147 ms
90,256 KB
testcase_27 AC 136 ms
89,756 KB
testcase_28 AC 149 ms
89,760 KB
testcase_29 AC 122 ms
77,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))
Q = int(input())
ans = 0
for a in A:
    ans += a * a
    
for _ in range(Q):
    C, K, D = map(int, input().split())
    C, D = C - 1, D - 1
    ans -= A[C] ** 2
    ans -= A[D] ** 2
    A[C] -= K
    A[D] += K
    ans += A[C] ** 2
    ans += A[D] ** 2
    print(ans)
    
0