#include <bits/stdc++.h>
using namespace std;
int n, m, d;
int cnt = 0;
struct cof {
  int in, time, bl;
  cof(int in = 0, int time = 0, int bl = 0) : in(in), time(time), bl(bl) {}
};
cof a[200050];
bool cmp1(const cof x, const cof y) { return x.time < y.time; }
bool cmp2(const cof x, const cof y) { return x.in < y.in; }
queue<cof> q;
int main() {
  scanf("%d%d%d", &n, &m, &d);
  for (int i(1); i <= n; i++) {
    scanf("%d", &a[i].time);
    a[i].in = i;
  }
  sort(a + 1, a + 1 + n, cmp1);
  cnt++;
  a[1].bl = cnt;
  q.push(a[1]);
  for (int i(2); i <= n; i++) {
    if (a[i].time > q.front().time + d) {
      a[i].bl = q.front().bl;
      q.pop();
      q.push(a[i]);
    } else {
      cnt++;
      a[i].bl = cnt;
      q.push(a[i]);
    }
  }
  sort(a + 1, a + 1 + n, cmp2);
  printf("%d\n", cnt);
  for (int i(1); i <= n; i++) printf("%d ", a[i].bl);
  return 0;
}
