就 差 一 个 点 了
  • 板块P1102 A-B 数对
  • 楼主F_C_
  • 当前回复2
  • 已保存回复2
  • 发布时间2022/3/25 15:13
  • 上次更新2023/10/28 05:44:15
查看原帖
就 差 一 个 点 了
606074
F_C_楼主2022/3/25 15:13
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,c,he=0,t;
    map<int,int> s;
    cin>>n>>c;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        if(s.count(t))
            s[t]++;
        else
            s[t]=1;
    }
    for(map<int,int>::iterator i=s.begin(); i!=s.end();i++)  
    {
        if(s.count(i->first-c))
        {
            long long t2=(i->second)*s[i->first-c];
            he+=t2;
        }
    }
    cout<<he;
    return 0;
}

92分

2022/3/25 15:13
加载中...