#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  int x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(int x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(int x) {
  write(x);
  puts("");
}
struct Node {
  int id, num, ans;
  inline bool operator<(const Node& x) const { return num > x.num; }
} a[200005];
int n, m, d, now, sum;
priority_queue<Node> que;
inline bool cmp(Node x, Node y) { return x.id < y.id; }
int main() {
  n = read();
  m = read();
  d = read();
  for (int i = 1; i <= n; i++) {
    a[i].num = -read();
    a[i].id = i;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) a[i].num = -a[i].num;
  sum = 1;
  now = 1;
  Node x = a[1];
  x.id = 1;
  a[1].ans = 1;
  que.push(x);
  for (int i = 2; i <= n; i++) {
    x = que.top();
    if (a[i].num - x.num > d) {
      que.pop();
      a[i].ans = x.id;
      x.num = a[i].num;
      que.push(x);
    } else {
      sum++;
      x.id = sum;
      a[i].ans = x.id;
      x.num = a[i].num;
      que.push(x);
    }
  }
  sort(a + 1, a + n + 1, cmp);
  writeln(sum);
  for (int i = 1; i <= n; i++) {
    write(a[i].ans);
    putchar(' ');
  }
  return 0;
}
