#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int d, n, m, ans;
int tag[N], bel[N];
int q[N << 1], l, r;
struct Q {
  int v, id;
} a[N];
inline bool cmp(const Q& x, const Q& y) { return x.v < y.v; }
int main() {
  int i, j, k, pre, res, num;
  scanf("%d%d%d", &n, &m, &d);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i].v);
  for (i = 1; i <= n; ++i) a[i].id = i;
  sort(a + 1, a + n + 1, cmp);
  bel[a[1].id] = ++ans;
  q[l = r] = 1;
  for (i = 2; i <= n; ++i) {
    if ((l > r) || a[q[l]].v + d >= a[i].v) {
      q[++r] = i;
      bel[a[i].id] = ++ans;
      continue;
    }
    bel[a[i].id] = bel[a[q[l]].id];
    q[++r] = i;
    l++;
  }
  printf("%d\n", ans);
  for (i = 1; i <= n; ++i) printf("%d ", bel[i]);
}
