文章
39
粉丝
74
获赞
1
访问
20.5k
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100010;
int n, d;
int w[N];
int main()
{
cin >> n >> d;
for (int i = 0; i < n; ++ i )
cin >> w[i];
sort(w, w + n);
int pre = -d, res = 0;
for (int i = 0; i < n; ++ i )
{
if (w[i] - pre >= d)
{
pre = w[i];
res ++;
}
}
cout << res << endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发