#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
struct node {
  long long x, y;
  bool operator<(const node& a) const { return x > a.x; }
} a[maxn];
int vis[maxn];
priority_queue<node> q, q1;
int main() {
  long long n, m, d;
  scanf("%lld%lld%lld", &n, &m, &d);
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i].x;
    a[i].y = i;
    q.push(a[i]);
  }
  while (!q.empty()) {
    node temp = q.top();
    q.pop();
    if (q1.empty()) {
      vis[temp.y] = cnt++;
      q1.push(temp);
    } else {
      node T;
      T = q1.top();
      if (temp.x > T.x + d) {
        vis[temp.y] = vis[T.y];
        q1.pop();
        q1.push(temp);
      } else {
        vis[temp.y] = cnt++;
        q1.push(temp);
      }
    }
  }
  printf("%d\n", cnt - 1);
  for (int i = 0; i < n; i++) {
    if (i) printf(" ");
    printf("%d", vis[i]);
  }
  printf("\n");
  return 0;
}
