結果
| 問題 | 
                            No.2306 [Cherry 5th Tune C] ウソツキタマシイ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-09-22 17:17:26 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 182 ms / 2,000 ms | 
| コード長 | 467 bytes | 
| コンパイル時間 | 1,918 ms | 
| コンパイル使用メモリ | 194,840 KB | 
| 最終ジャッジ日時 | 2025-02-17 00:06:50 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 30 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
	cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll N,M,Q,C,K,D,S=0;
    cin>>N>>M;
    vector<ll> A(M);
    for(ll i=0;i<M;i++){
        cin>>A[i];
        S+=A[i]*A[i];
    }
    cin>>Q;
    for(ll q=0;q<Q;q++){
        cin>>C>>K>>D;
        C--;D--;
        S-=A[C]*A[C]+A[D]*A[D];
        A[C]-=K;
        A[D]+=K;
        S+=A[C]*A[C]+A[D]*A[D];
        cout<<S<<endl;
    }
}