#include <iostream>
#include <map>
using namespace std;
typedef long long LL;
map <int, int> mp;
int main()
{
ios::sync_with_stdio(false);//cin<<scanf<cin(关闭流同步)此处是关键!!!使用了这一句就不要用scanf和printf啦!
int n, a, b, index, value;
LL ans = 0; //此处也需注意~
cin >> n >> a >> b;
while(a --)
{
cin >> index >> value;
mp[index] = value;
}
while(b --)
{
cin >> index >> value;
if(mp[index] != 0)
{
ans += (LL)mp[index] * (LL)value;//这里也有坑!
}
}
cout << ans << endl;
return 0;
}
参考博客:https://blog.csdn.net/qq_38632614/article/details/107736600