#include <bits/stdc++.h>
const int MAXN = 2e5 + 10;
int a[MAXN];
int ans[MAXN];
int main() {
  int n, m, d;
  scanf("%d%d%d", &n, &m, &d);
  std::set<std::pair<int, int> > s;
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    s.insert({a[i], i});
  }
  int cur = 1, day = 1;
  for (int i = 1; i <= n; i++) {
    auto it = s.lower_bound({cur, -1});
    if (it == s.end()) {
      day++;
      cur = 1;
      it = s.lower_bound({cur, -1});
    }
    ans[it->second] = day;
    if (it->first + d + 1 > m) {
      day++;
      cur = 1;
    } else {
      cur = it->first + d + 1;
    }
    s.erase(it);
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    res = std::max(res, ans[i]);
  }
  printf("%d\n", res);
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  printf("\n");
}
