初级守护
#include<iostream>
#include<iomanip>
#include<cmath>
#include<math.h>
#include<map>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int find(int start,int end,int x){
int left,mid,right;
left=start;
right=end;
while(left<=right){
mid=(left+right)/2;
if(a[mid]==x){
int count=1,i;
i=mid-1;
while(i>=start&&a[i]==x){
count++,i--;
i=mid+1;
while(i<=end&&a[i]==x){
count++,i++;
return count;
}//3 while
}//2 while
}else if(a[mid]<x){
left=mid+1;
}else{
right=mid-1;
}//1 else
}//1 while
return 0;
}//1 int
int main(){
int n,c;
cin>>n>>c;
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
int count=0;
for(int i=0;i<n-1;i++){
count+=find(i+1,n-1,a[i]+c);
}
cout<<count<<endl;
return 0;
}
编译错误!!!