#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int ans[maxn];
struct Node {
  int num, id;
  bool operator<(const Node& a) const { return num > a.num; }
} node[maxn];
priority_queue<Node> qq;
bool cmp(Node a, Node b) { return a.num < b.num; }
int main() {
  int n, m, d;
  scanf("%d%d%d", &n, &m, &d);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &node[i].num);
    node[i].id = i;
  }
  sort(node + 1, node + 1 + n, cmp);
  qq.push(node[1]);
  ans[node[1].id] = 1;
  int kk = 1;
  for (int i = 2; i <= n; i++) {
    Node x = qq.top();
    if (x.num + d < node[i].num) {
      qq.pop();
      qq.push(node[i]);
      ans[node[i].id] = ans[x.id];
    } else {
      qq.push(node[i]);
      ans[node[i].id] = ++kk;
    }
  }
  printf("%d\n", qq.size());
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  printf("\n");
}
