题目很简单,应该是服务器跑的很慢,1.968s/2s,5e5的数据,map一次要2s么?
/* Author : Rshs */
#include<bits/stdc++.h>
using namespace std;
#define FI first
#define SE second
#define LL long long
#define LDB long double
#define MP make_pair
#define PII pair<int,int>
#define SZ(a) (int)a.size()
#define DB1(a) cerr<<(#a)<<'='<<a<<endl
#define DB2(a,b) cerr<<(#a)<<'='<<a<<' '<<(#b)<<'='<<b<<endl
#define DB3(a,b,c) cerr<<(#a)<<'='<<a<<' '<<(#b)<<'='<<b<<' '<<(#c)<<'='<<c<<endl
const LDB pai = acos(-1.0L);
const LDB eps = 1e-10;
const LL mod = 1e9+7;
const int MXN = 1e6+5;
inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
inline int Mul(int x,int y) {return 1LL*x*y%mod;}
inline int Pow(int x,LL y){int res=1;while(y){if(y&1)res=1LL*res*x%mod;x=1LL*x*x%mod;y>>=1;}return res;}
map<int,int>ma;
int main(){
int n,a,b;cin>>n>>a>>b;
for(int i=1;i<=a;i++){
int sa,sb;scanf("%d %d",&sa,&sb);
ma[sa]=sb;
}
LL ans=0;
for(int i=1;i<=b;i++){
int sa,sb;scanf("%d %d",&sa,&sb);
auto it=ma.find(sa);
if(it!=ma.end()){
ans=ans+(LL)sb*(LL)it->SE;
}
}
cout<<ans<<'\n';
return 0;
}