输入卡常数1e9,必须要开ios::sync_with_stdio(false)
,用scanf
都不行
算法:模拟
#include <iostream>
#include <unordered_map>
#include <cstdio>
#include <map>
using namespace std;
typedef long long LL;
int n,a,b;
unordered_map<int,int> u;
int main()
{
ios::sync_with_stdio(false); // 输入1e9卡常,必须要开这个,scanf都不行,佛了
cin >> n >> a >> b;
//scanf("%d%d%d",&n,&a,&b);
int x,y;
for(int i=0;i<a;++i)
{
cin >> x >> y;
//scanf("%d%d",&x,&y);
u[x] = y;
}
LL res = 0;
for(int i=0;i<b;++i)
{
cin >> x >> y;
//scanf("%d%d",&x,&y);
if(u[x] != 0) res += (u[x] * y);
}
cout<<res<<endl;
//printf("%lld\n",res);
return 0;
}