求助 WA
查看原帖
求助 WA
938449
xiaoming007楼主2023/8/14 19:13
#include <iostream>
#include <map>
typedef long long ll;
std::map<ll, int> mp;
int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	int n, q;
	ll more = 0, all = 0;
	std::cin >> n;
	for (int i = 1, x; i <= n; ++i) {
		std::cin >> x;
		mp[x]++;
		all += x;
	}
	std::cin >> q;
	while (q--) {
		std::string type;
		ll x, y;
		std::cin >> type >> x;
		if (type[0] == 'I') more += x;
		else {
			std::cin >> y;
			x -= more, y -= more;
			if (x != y && mp.count(x)) {
				all += (y - x) * mp[x];
				//std::cout << "\n" << (y - x) * mp[x] << ' ' << mp[x] <<"\n";
				mp[y] += mp[x];
				mp.erase(x);
			}
		}
		std::cout << all + more * n << '\n';
	}
	return 0;
}

record

样例可过,

2023/8/14 19:13
加载中...