Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- int n; cin >> n;
- map<long long, int> f;
- long long sum = 0;
- for (int i = 0; i < n; ++i) {
- int x; cin >> x;
- ++f[x], sum += x;
- }
- long long offset = 0;
- int q; cin >> q;
- while (q--) {
- string s; cin >> s;
- if (s == "INFLATION") {
- long long x; cin >> x;
- offset += x;
- sum += n*x;
- } else {
- long long x, y; cin >> x >> y;
- x -= offset, y -= offset;
- if (f.count(x)) {
- int c = f[x];
- f.erase(x);
- f[y] += c;
- sum += c*(y-x);
- }
- }
- cout << sum << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement