#include <bits/stdc++.h>
using namespace std;
int n, m, d, cnt;
int a[(200000 + 10)], id[(200000 + 10)], bel[(200000 + 10)];
set<pair<int, int> > S;
set<pair<int, int> >::iterator it;
int read() {
  int sum = 0;
  char c = getchar(), flag = ' ';
  while (c < '0' || c > '9') flag = c, c = getchar();
  while (c >= '0' && c <= '9')
    sum = (sum << 1) + (sum << 3) + c - '0', c = getchar();
  if (flag == '-') sum *= -1;
  return sum;
}
bool cmp(const int &x, const int &y) { return a[x] < a[y]; }
int main() {
  n = read(), m = read(), d = read();
  for (int i = 1; i <= n; i++) a[i] = read(), id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    it = S.lower_bound(make_pair(a[id[i]] - d, 0));
    if (it != S.begin()) {
      --it;
      bel[id[i]] = it->second;
      S.erase(it);
      S.insert(make_pair(a[id[i]], bel[id[i]]));
    } else {
      bel[id[i]] = ++cnt;
      S.insert(make_pair(a[id[i]], cnt));
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++) printf("%d ", bel[i]);
  return 0;
}
