#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define MOD 1000000007 int main() { int n, d; cin >> n >> d; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector b = a; sort(b.begin(), b.end()); for (int i = 0; i < n; ++i) { int ok = -1, ng = n; while (1 < abs(ok - ng)) { int mid = (ok + ng) / 2; if (b[mid] <= a[i] - d) { ok = mid; } else { ng = mid; } } cout << ok + 1 << endl; } return 0; }