题目如下:

1<=n,x,a[i]<=2000
不知道为什么爆零了(可以帮我看一下吗)
测试数据(样例)
输入
6 3
1 2 5 7 8 11
输出
2
我的代码:
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+5;
int n,l[N],m,ans;
bool find(int x){
for(int i=0;i<n;i++){
if(x==l[i]) return true;
}
return false;
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>l[i];
}
for(int i=0;i<n;i++){
if(find(l[i]-m)&&find(l[i]+m)) ans++;
}
cout<<ans;
return 0;
}
感觉这是一道语法题很简单,样例也过了,但就是错了 (无语)