結果
問題 | No.2306 [Cherry 5th Tune C] ウソツキタマシイ |
ユーザー |
|
提出日時 | 2023-07-08 14:25:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 516 ms / 2,000 ms |
コード長 | 1,007 bytes |
コンパイル時間 | 914 ms |
コンパイル使用メモリ | 108,848 KB |
最終ジャッジ日時 | 2025-02-15 08:57:28 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include<iostream> #include<set> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> #include<numeric> #include<queue> #include<cmath> using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair<ll,ll> P; typedef pair<int,P> PP; const ll MOD=998244353; const double PI=acos(-1); int main(){ int N,M; cin>>N>>M; map<int,ll> mp; for(int i=1;i<=M;i++){ ll a; cin>>a; mp[i]=a; } ll ans=0; for(auto [c,num]:mp){ ans+=1LL*num*num; } int Q; cin>>Q; vector<ll> outputans(Q); for(int q=0;q<Q;q++){ int c,k,d; cin>>c>>k>>d; ans-=mp[c]*mp[c]; ans-=mp[d]*mp[d]; mp[c]-=k; mp[d]+=k; ans+=mp[c]*mp[c]; ans+=mp[d]*mp[d]; // for(auto [v,num]:mp){ // cout<<"v="<<v<<",num="<<num<<endl; // } outputans[q]=ans; } for(ll v:outputans){ cout<<v<<endl; } }