ccf_202006-2

运用map,秒了

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
26
27
28
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main()
{
int n,a,b;
cin >> n >> a >> b;
map<long ,long> mymap;
for(int i = 0;i<a;i++){
long long tmp,tmp1;
cin >>tmp >> tmp1;
mymap.insert(make_pair(tmp,tmp1));
}
long long res =0;
for(int i = 0;i<b;i++){
long long tmp,tmp1;
cin >> tmp >> tmp1;
auto it = mymap.find(tmp);
if(it != mymap.end()){
res += tmp1 * it->second;
}
}
cout << res << endl;


return 0;
}

ccf_202006-2
http://blog.ulna520.com/2024/09/27/ccf_202006-2/
Veröffentlicht am
September 27, 2024
Urheberrechtshinweis