#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, d;
  set<pair<long long int, long long int> > q;
  cin >> n >> m >> d;
  vector<long long int> A(n);
  for (long long int i = 0; i < n; i++) {
    long long int t;
    cin >> t;
    A[i] = t;
    q.insert(make_pair(A[i], i));
  }
  long long int cnt = 0;
  vector<long long int> ans(n);
  while (!q.empty()) {
    ++cnt;
    long long int pos = q.begin()->second;
    ans[pos] = cnt;
    q.erase(q.begin());
    while (true) {
      auto it = q.lower_bound(make_pair(A[pos] + 1 + d, 0));
      if (it == q.end()) {
        break;
      }
      pos = it->second;
      q.erase(it);
      ans[pos] = cnt;
    }
  }
  cout << cnt << endl;
  for (long long int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
