卡点2 求指点
查看原帖
卡点2 求指点
1017495
chenhaiyang楼主2024/5/28 19:37
#include <iostream>
#include <map>
#include <math.h>
using namespace std;

int n,c,t;
int main(){
    cin>>n>>c;
    map<int,int> m;
    for(int i=0;i<n;i++){
        cin>>t;
        m[t]+=1;
    }
    long long res=0;
    for(map<int,int>::iterator it=m.begin();it!=m.end();it++)res=res+(long long)m[it->first]*(long long)m[abs(c-it->first)];
    
    cout << res <<endl;
    return 0;
}
2024/5/28 19:37
加载中...