#pragma GCC optimize("Ofast") #include #include #include #include #include #include #include #include #include const long long INFL = 1e17+7; const long long INFI = 1e9+7; const long long MOD = 1e9+7; const double EXP = 1e-8; const double PI=acos(-1); using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n,d; cin >> n >> d; vector a(n+1); vector b(n+1); a[0]=b[0]=0; for(int i=1;i<=n;i++){ cin >> a[i]; b[i]=a[i]; } sort(b.begin(),b.end()); int start=0; int end=b.size()-1; int target; int id=0; int mid; vector ans; while(1){ int target=a[id]-d; //cout << "target : " << target << endl; if(ans.size()==b.size())break; mid=(end+start)/2; //cout << "mid : " << mid << endl; if(b[mid]>target){ end=mid; //cout << "start : " << start << " end : " << end << endl; }else if(b[mid]<=target){ start=mid; //cout << "start : " << start << " end : " << end << endl; } if(end-start<=1){ ans.push_back(start); //cout << ans[id] << endl; id++; start=0; end=b.size()-1; } } for(int i=1;i