http://codeforces.com/contest/940/problem/A
直线上有n个点,去掉最少的点,使最远两点距离不超过d。
暴力
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define ll long long
int n,d;
int a[105];
int ans=999;
int main(){
cin >> n >> d;
for (int i=0;i<n;i++){
cin >> a[i];
}
sort(a,a+n);
for (int l=0;l<n;l++){
for (int r=l;r<n;r++){
if (a[r]-a[l]<=d){
ans=min(ans,l+n-1-r);
}
}
}
cout << ans << endl;
}