【CCF 202006-2】稀疏向量

#include
#include
#include
#include
#include
using namespace std;
const int maxn = 5e4 + 100;
#define TLE ios::sync_with_stdio(0),cin.tie(0)
const int INF = 0x3f3f3f3f;
#define ll long long
int main() {
	TLE;
	ll n, a, b;
	cin >> n >> a >> b;
	map<ll, ll> index;
	ll t1, t2;
	for (int i = 0; i < a; i++) {
		cin >> t1 >> t2;
		index[t1] = t2;
	}
	ll sum = 0;
	for (int i = 0; i < b; i++) {
		cin >> t1 >> t2;
		map<ll, ll>::iterator iter = index.find(t1);
		if (iter != index.end()) {
			/*printf("%d %d %d\n", t1, t2, index[t1]);*/
			sum += 1ll * index[t1] * t2;
		}
	}
	printf("%lld\n", sum);
}

你可能感兴趣的:(【CCF 202006-2】稀疏向量)