#include <bits/stdc++.h>
using namespace std;
long long n;
long long m;
long long d;
struct node {
  long long id;
  long long val;
} a[200005];
bool cmp(node a, node b) { return a.val < b.val; }
long long ans1[200005];
long long ans2;
int main() {
  scanf("%lld %lld %lld", &n, &m, &d);
  for (long long i = 1; i <= n; ++i) scanf("%lld", &a[a[i].id = i].val);
  sort(a + 1, a + 1 + n, cmp);
  long long p = 1;
  for (long long i = 1; i <= n; ++i) {
    if (ans1[a[i].id] == 0) ans1[a[i].id] = ++ans2;
    while (p <= n && (ans1[a[p].id] || a[p].val - a[i].val <= d)) ++p;
    ans1[a[p].id] = ans1[a[i].id];
  }
  printf("%lld\n", ans2);
  for (long long i = 1; i <= n; ++i)
    printf("%lld%c", ans1[i], i == n ? '\n' : ' ');
  return 0;
}
