#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, k, n, i, d, a, b;
  scanf("%lld", &n);
  scanf("%lld", &k);
  scanf("%lld", &d);
  map<long long int, long long int> m;
  map<long long int, long long int> ans;
  map<long long int, long long int>::iterator it1;
  map<long long int, long long int>::iterator it;
  vector<long long int> v;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &k);
    m[k] = 0;
    ans[k] = 0;
    v.push_back(k);
  }
  int day = 0;
  while (m.size() != 0) {
    day++;
    a = m.begin()->first;
    ans[a] = day;
    m.erase(a);
    while (1) {
      it = m.lower_bound(a + d + 1);
      if (it != m.end()) {
        a = it->first;
        ans[a] = day;
        m.erase(a);
      } else
        break;
    }
  }
  cout << day << "\n";
  for (i = 0; i < v.size(); i++) cout << ans[v[i]] << " ";
}
