#include <bits/stdc++.h>
using namespace std;
int res[200003];
int main() {
  int n, m, d;
  scanf("%d %d %d", &n, &m, &d);
  set<pair<int, int> > sorted;
  for (int i = 0; i < n; i++) {
    int v;
    scanf("%d", &v);
    sorted.insert((make_pair(v, i)));
  }
  vector<vector<pair<int, int> > > R;
  int index = 0;
  long long current = 0;
  int popSize = 0;
  bool input = false;
  while (sorted.size() != 0) {
    vector<pair<int, int> > newV;
    auto first = sorted.begin();
    int firstV = first->first;
    res[first->second] = R.size() + 1;
    newV.push_back(*first);
    sorted.erase(first);
    while (true) {
      pair<int, int> v = {firstV + 1 + d, 0};
      auto search = sorted.lower_bound(v);
      if (search != sorted.end()) {
        firstV = search->first;
        res[search->second] = R.size() + 1;
        newV.push_back(*search);
        sorted.erase(search);
      } else
        break;
    }
    R.push_back(newV);
  }
  printf("%d\n", R.size());
  for (int i = 0; i < n; i++) printf("%d ", res[i]);
  printf("\n");
  return 0;
}
