結果
問題 | No.2306 [Cherry 5th Tune C] ウソツキタマシイ |
ユーザー | 👑 Kazun |
提出日時 | 2023-02-16 03:32:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 141 ms / 2,000 ms |
コード長 | 496 bytes |
コンパイル時間 | 476 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 90,496 KB |
最終ジャッジ日時 | 2024-07-22 04:02:59 |
合計ジャッジ時間 | 7,043 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
def solve():N,M=map(int,input().split())A=[0]+list(map(int,input().split()))power=sum(a*a for a in A)Q=int(input())Ans=[0]*Qfor q in range(Q):C,K,D=map(int,input().split())power+=(A[D]+K)*(A[D]+K)+(A[C]-K)*(A[C]-K)-(A[D]*A[D]+A[C]*A[C])A[D]+=K; A[C]-=KAns[q]=powerreturn Ans#==================================================import sysinput=sys.stdin.readlinewrite=sys.stdout.writewrite("\n".join(map(str,solve())))