这题主要是空间的处理
#include<bits/stdc++.h>
using namespace std;
map<int, int>p;
int n, a, b;
long long sum = 0;//防止数据溢出
int main() {
ios::sync_with_stdio(false);
cin >> n >> a >> b;
int x, y;
int i;
for (i = 1; i <= a; i++) {
cin >> x >> y;
p[x] = y;
}
for (i = 1; i <= b; i++) {
cin >> x >> y;
if (p[x]!=0) {
sum += y * p[x];
}
}
cout << sum;
}