CSP 202006-2 稀疏向量 //卡常

题目很简单,应该是服务器跑的很慢,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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值