結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー koarakko5555koarakko5555
提出日時 2023-05-19 21:47:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 377 ms / 2,000 ms
コード長 414 bytes
コンパイル時間 1,582 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 90,460 KB
最終ジャッジ日時 2023-08-22 23:46:48
合計ジャッジ時間 11,474 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,140 KB
testcase_01 AC 74 ms
71,012 KB
testcase_02 AC 87 ms
75,372 KB
testcase_03 AC 74 ms
71,416 KB
testcase_04 AC 94 ms
76,052 KB
testcase_05 AC 94 ms
76,096 KB
testcase_06 AC 101 ms
76,124 KB
testcase_07 AC 278 ms
86,948 KB
testcase_08 AC 141 ms
81,880 KB
testcase_09 AC 204 ms
87,392 KB
testcase_10 AC 206 ms
78,352 KB
testcase_11 AC 223 ms
83,264 KB
testcase_12 AC 258 ms
90,076 KB
testcase_13 AC 203 ms
88,532 KB
testcase_14 AC 192 ms
83,964 KB
testcase_15 AC 327 ms
83,352 KB
testcase_16 AC 330 ms
79,228 KB
testcase_17 AC 368 ms
90,124 KB
testcase_18 AC 365 ms
90,456 KB
testcase_19 AC 374 ms
90,208 KB
testcase_20 AC 362 ms
90,144 KB
testcase_21 AC 368 ms
90,212 KB
testcase_22 AC 365 ms
90,148 KB
testcase_23 AC 364 ms
90,460 KB
testcase_24 AC 371 ms
90,016 KB
testcase_25 AC 366 ms
90,200 KB
testcase_26 AC 377 ms
90,236 KB
testcase_27 AC 332 ms
89,760 KB
testcase_28 AC 375 ms
89,600 KB
testcase_29 AC 330 ms
78,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A = list(map(int, input().split()))
ans1 = 0
for i in range(M):
    ans1 += A[i]*A[i]
Q = int(input())
for _ in range(Q):
    c, k, d = map(int, input().split())
    c -= 1
    d -= 1
    diff1 = (A[d]**2 - (A[d]+k)**2)
    diff2 = (A[c]**2 - max(0, (A[c]-k))**2)
    ans = ans1 - (diff1 + diff2)
    print(ans)

    #修正
    A[d] += k
    A[c] = max(0, A[c]-k)
    ans1 = ans

0