#include <bits/stdc++.h>
using namespace std;
int m, n, c, a[210000], b[1111111], d, e, xyqwd = 10000000;
set<pair<int, int> > s;
pair<int, int> pp;
int main() {
  cin >> m >> n >> d;
  for (int x = 1; x <= m; x++) {
    cin >> a[x];
    pp.first = a[x];
    pp.second = x;
    s.insert(pp);
  }
  n = 1;
  while (!s.empty()) {
    int p = s.begin()->second;
    set<pair<int, int> >::iterator it;
    pair<int, int> qq;
    s.erase(s.begin());
    b[p] = n;
    qq.first = a[p] + d;
    qq.second = xyqwd;
    while (it != s.end()) {
      qq.first = a[p] + d;
      qq.second = xyqwd;
      it = s.upper_bound(qq);
      if (it == s.end()) {
        break;
      }
      p = it->second;
      b[p] = n;
      s.erase(it);
    }
    n++;
  }
  cout << n - 1 << endl;
  for (int x = 1; x <= m; x++) {
    cout << b[x] << " ";
  }
}
