#include <bits/stdc++.h>
class query {
 public:
  int id, x, ans;
} a[262144];
int h[262144], nh;
int que[262144], cq, nq;
int main() {
  int n, m, d;
  scanf("%d%d%d", &n, &m, &d), ++d;
  for (int i = 0; i < n; ++i) a[i].id = i, scanf("%d", &a[i].x);
  std::sort(a, a + n, [](query a, query b) { return a.x < b.x; });
  for (int i = 0; i < n; ++i) {
    int k = cq == nq || a[i].x - h[que[cq]] < d ? nh++ : que[cq++];
    a[i].ans = k + 1, h[k] = a[i].x, que[nq++] = k;
  }
  std::sort(a, a + n, [](query a, query b) { return a.id < b.id; });
  printf("%d\n", nh);
  for (int i = 0; i < n; ++i) printf(" %d" + !i, a[i].ans);
  printf("\n");
  return 0;
}
