CCF认证考试题解目录
C++题解
ios::sync_with_stdio(false);加上这句代码可以加速数据的读入,事实上取消cin和scanf的同步,cin和scanf的速度是差不多的!详情请见OJ神器 - sync_with_stdio。
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long res =0;
map<int,int> mm;
ios::sync_with_stdio(false);
int N,A,B;
cin>>N>>A>>B;
int x,y;
while(A--)
{
cin>>x>>y;
mm[x]=y;
}
while(B--)
{
cin>>x>>y;
if(mm[x]!=0)
{
res+=y*mm[x];
}
}
cout<<res<<endl;
return 0;
}