1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include<bits/stdc++.h>
using namespace std;
int n,a,b,x,y;
long long ans=0;
map<int,int> mp1,mp2;
int main(){
scanf("%d %d %d",&n,&a,&b);
for(int i=0;i<a;i++){
scanf("%d %d",&x,&y);
mp1[x]=y;
}
for(int i=0;i<b;i++){
scanf("%d %d",&x,&y);
mp2[x]=y;
}
for(auto &v:mp1){
if(mp2.count(v.first))
ans+=(long long)(v.second*mp2[v.first]);
}
printf("%lld",ans);
return 0;
}
|