题解 | 数对计数

数对计数

https://www.nowcoder.com/practice/7d05171e7e0e4c6086be233769e01d94

#include <iostream>
using namespace std;
#include<set>
int main(){
int n,c;
cin>>n>>c;
multiset<int>a;
while(n--){

int b;
cin>>b;
a.insert(b);




}
int e=0;
for (auto it=a.begin();it!=a.end();it++){

e+=a.count(*it+c);



}
if (c==0){
    cout<<n;
}
else{
cout<<e;
}


    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务