#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, d, i, j, l, a[200005], c[200005];
  set<pair<long long int, long long int> > v;
  cin >> n >> m >> d;
  for (long long int i = 0; i <= n - 1; i++)
    cin >> a[i], v.insert(make_pair(a[i], i));
  j = 0;
  l = -1;
  pair<long long int, long long int> k;
  while (v.size() > 0) {
    long long int s = (*v.begin()).second;
    v.erase(v.begin());
    l++;
    while (1) {
      c[s] = l;
      if (v.size() == 0) break;
      set<pair<long long int, long long int> >::iterator k1 =
          v.lower_bound(pair<long long int, long long int>(a[s] + d + 1, -1));
      if (k1 == v.end()) break;
      s = (*k1).second;
      v.erase(k1);
    }
  }
  cout << l + 1 << '\n';
  for (long long int i = 0; i <= n - 1; i++) cout << c[i] + 1 << " ";
  return 0;
}
