#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
int f[maxn];
int b[maxn];
int c[maxn];
bool cmp(int x, int y) { return a[x] < a[y]; }
int now = 0;
int n, m, d;
multiset<pair<int, int> > S;
bool check(int x) {
  if (S.empty()) return 0;
  auto it = S.begin();
  if (a[x] - ((*it).first) - 1 >= d) {
    int idx = (*it).second;
    pair<int, int> tmp = pair<int, int>(a[x], idx);
    S.erase(it);
    S.insert(tmp);
    c[x] = idx;
    return 1;
  }
  return 0;
}
int main() {
  scanf("%d %d %d", &n, &m, &d);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    f[i] = i;
  }
  sort(f + 1, f + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    int idx = f[i];
    if (!check(idx)) {
      ++now;
      S.insert(pair<int, int>(a[idx], now));
      c[idx] = now;
    }
  }
  printf("%d\n", now);
  for (int i = 1; i <= n; i++) printf("%d ", c[i]);
  puts("");
}
