제출 #1367934

#제출 시각아이디문제언어결과실행 시간메모리
1367934ap0100Inflation (EGOI23_inflation)C++20
42 / 100
3094 ms3552 KiB
//A1-Inflation ('23 EGOI)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
int n, q;

void add(vector<ll> &p, int x) {
    for (int i=0; i<p.size(); i++) {
        p[i]+=x;
    }
}

void mod(vector<ll> &p, int x, int y) {
    for (int i=0; i<p.size(); i++) {
        if (p[i]==x) p[i]=y;
    }
}

ll sum(vector<ll> &p) {
    ll sum=0;
    for (int i=0; i<p.size(); i++) {
        sum+=p[i];
    }

    return sum;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    vector<ll> prices(n);
    for (int i=0; i<n; i++) {
        cin >> prices[i];
    }

    cin >> q;
    string s;
    vector<ll> res(q);
    for (int i=0; i<q; i++) {
        cin >> s;
        ll x,y;
        if (s=="INFLATION") {
            cin >> x;
            add(prices, x);
        }else {
            cin >> x >> y;
            mod(prices, x, y);
        }
        res[i]=sum(prices);
    }

    for (auto r: res) cout << r << '\n';


    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…