#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 1e5 + 19;
long long A[N], day[N];
signed main() {
  long long n, m, d;
  set<pair<long long, int> > S;
  n = read();
  m = read();
  d = read();
  for (int i = 1; i <= n; ++i) {
    long long x;
    x = read();
    S.insert(pair<long long, int>(x, i));
  }
  int now = 0;
  while (S.size()) {
    ++now;
    pair<long long, int> tmp = *S.begin();
    long long s = tmp.first;
    day[tmp.second] = now;
    S.erase(S.begin());
    for (auto iter = S.lower_bound(pair<long long, int>(s + d + 1, 0));
         iter != S.end();
         iter = S.lower_bound(pair<long long, int>(s + d + 1, 0))) {
      day[iter->second] = now;
      s = iter->first;
      S.erase(iter);
    }
  }
  printf("%d\n", now);
  for (int i = 1; i <= n; ++i) printf("%I64d ", day[i]);
  return 0;
}
