結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー titiatitia
提出日時 2023-05-19 21:49:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 447 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 10,700 KB
実行使用メモリ 19,548 KB
最終ジャッジ日時 2023-08-22 23:49:13
合計ジャッジ時間 10,652 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,868 KB
testcase_01 AC 16 ms
7,764 KB
testcase_02 AC 19 ms
8,340 KB
testcase_03 AC 16 ms
7,816 KB
testcase_04 AC 19 ms
8,136 KB
testcase_05 AC 20 ms
8,168 KB
testcase_06 AC 19 ms
8,224 KB
testcase_07 AC 281 ms
16,540 KB
testcase_08 AC 68 ms
13,164 KB
testcase_09 AC 173 ms
17,048 KB
testcase_10 AC 156 ms
9,180 KB
testcase_11 AC 196 ms
14,140 KB
testcase_12 AC 265 ms
18,932 KB
testcase_13 AC 178 ms
17,720 KB
testcase_14 AC 150 ms
15,104 KB
testcase_15 AC 355 ms
14,356 KB
testcase_16 AC 365 ms
10,752 KB
testcase_17 AC 443 ms
19,516 KB
testcase_18 AC 440 ms
19,436 KB
testcase_19 AC 441 ms
19,488 KB
testcase_20 AC 433 ms
19,432 KB
testcase_21 AC 438 ms
19,464 KB
testcase_22 AC 434 ms
19,548 KB
testcase_23 AC 431 ms
19,536 KB
testcase_24 AC 435 ms
19,548 KB
testcase_25 AC 433 ms
19,492 KB
testcase_26 AC 447 ms
19,528 KB
testcase_27 AC 338 ms
9,680 KB
testcase_28 AC 358 ms
9,652 KB
testcase_29 AC 339 ms
8,112 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 tests in range(Q):
    c,k,d=map(int,input().split())
    c-=1
    ANS-=A[c]*A[c]

    A[c]-=k
    ANS+=A[c]*A[c]

    d-=1
    ANS-=A[d]*A[d]
    A[d]+=k
    ANS+=A[d]*A[d]

    print(ANS)
0