Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define loop(i,b,e) for(int i=b;i<=e;i++)
- #define pf printf
- #define sf scanf
- int n,d,b,e,t[101],ans=1e7;
- int main() {
- sf("%d%d",&n,&d);
- loop(i,0,n-1)
- sf("%d",&t[i]);
- if(n == 1) {
- pf("0");
- return 0;
- }
- sort(t,t+n);
- loop(i,0,n-1) {
- loop(j,0,n-1) {
- if(t[i]-t[j] == d) {
- ans = min(ans,n-i+j-1);
- }
- }
- }
- pf("%d",ans);
- }
Advertisement
Add Comment
Please, Sign In to add comment