#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w,
    x, y, z, ans, maxi, mini, res;
string s1, s2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> d;
  set<pair<long long, long long> > s;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    s.insert({x, i + 1});
  }
  j = 1;
  long long ans[n + 4];
  while (!s.empty()) {
    x = 0;
    set<pair<long long, long long> >::iterator it;
    while ((it = s.lower_bound({x, 0})) != s.end()) {
      ans[it->second] = j;
      x = it->first + d + 1;
      s.erase(it);
    }
    j++;
  }
  cout << --j << endl;
  for (long long i = 1; i < n + 1; i++) cout << ans[i] << " ";
  return 0;
}
