제출 #1352536

#제출 시각아이디문제언어결과실행 시간메모리
1352536hsuan._.0528Inflation (EGOI23_inflation)C++20
42 / 100
311 ms20764 KiB
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pii pair<LL, LL>
#define S second
#define F first
const int maxn = 3e5;

int n, q;
LL h=0, ans=0;
LL p[maxn];
set<pii> st;
map<LL, LL> mp;


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n;
    for(int i=1; i<=n; i++){
      cin>>p[i];
      ans+=p[i];
      mp[ p[i] ]++;
    }
    cin>>q;
    while(q--){
        string s;
        LL x, y;
        cin>>s;
        if(s=="INFLATION"){
            cin>>x;
            h+=x;
        }else if(s=="SET"){
            cin>>x>>y;
            LL now = mp[x-h];
            if(x!=y and now){
                ans -= (x-h) * now;
                ans += (y-h) * now;
                mp[y-h] += now;
                mp.erase(x-h);
            }
        }
        cout<<ans+h*n<<"\n";
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...