#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, d;
  scanf("%d %d %d", &n, &m, &d);
  int ans[n];
  set<pair<int, int>> s;
  for (int i = 0, in; i < n; i++) {
    scanf("%d", &in);
    s.insert(pair<int, int>(in, i));
  }
  int day = 1;
  while (!s.empty()) {
    auto cur = s.begin();
    while (true) {
      ans[cur->second] = day;
      auto temp = s.lower_bound(pair<int, int>(cur->first + d + 1, 0));
      s.erase(cur);
      if (temp == s.end()) break;
      cur = temp;
    }
    ++day;
  }
  printf("%d\n", day - 1);
  for (int i = 0; i < n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
