#include <bits/stdc++.h>
using namespace std;
void machayenge() {
  long long int n, m, d;
  cin >> n >> m >> d;
  long long int ans[n];
  long long int a[n];
  set<pair<long long int, long long int> > q;
  for (long long int i = 0; i < n; ++i) {
    long long int tmp;
    cin >> tmp;
    a[i] = tmp;
    q.insert({tmp, i});
  }
  long long int cou = 0;
  while (!q.empty()) {
    cou++;
    long long int tmp = q.begin()->first + d + 1;
    ans[q.begin()->second] = cou;
    q.erase(q.begin());
    while (true) {
      auto i = q.lower_bound({tmp, 0});
      if (i == q.end()) break;
      ans[i->second] = cou;
      tmp = i->first + d + 1;
      q.erase(i);
    }
  }
  cout << cou << "\n";
  for (long long int i = 0; i < n; ++i) cout << ans[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  machayenge();
  return 0;
}
