一二三四五 上山打老虎

CCF-CSP-2020-06-2稀疏向量

题目链接:http://118.190.20.162/view.page?gpid=T104
思路:

代码:

#include<bits/stdc++.h>

using namespace std;
map<int,int>mp;
int main (){
    int n,a,b,l,r;
    cin>>n>>a>>b;
    for(int i=0;i<a;i++){
        cin>>l>>r;
        mp[l]=r;
    }
    long long ans=0;
    for(int i=0;i<b;i++){
        cin>>l>>r;
        if(mp.find(l)!=mp.end()){
            ans+=mp[l]*r;
        }
    }
    cout<<ans;
    return 0;
}
/*
10 3 4
4 5
7 -3
10 1
1 10
4  20
5 30
7 40
*/

posted @ 2021-03-16 09:42  黒川川  阅读(110)  评论(0)    收藏  举报