#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
long long a[N], ans[N];
pair<long long, long long> b[N];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m, d, k;
  cin >> n >> m >> d;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = {a[i], i};
  }
  sort(b + 1, b + n + 1);
  k = 0;
  for (int i = 1; i <= n; i++) {
    if (q.empty()) {
      ans[b[i].second] = ++k;
      q.push({b[i].first, k});
    } else {
      pair<long long, long long> t = q.top();
      if (t.first + d >= b[i].first) {
        ans[b[i].second] = ++k;
        q.push({b[i].first, k});
      } else {
        q.pop();
        ans[b[i].second] = t.second;
        q.push({b[i].first, t.second});
      }
    }
  }
  cout << k << '\n';
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " \n"[i == n];
  }
}
