#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long int m, d;
  cin >> n >> m >> d;
  pair<long long, long long int> a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a, a + n);
  long long int ans[n];
  multimap<long long int, long long int> hash;
  ans[a[0].second] = 1;
  hash.insert(make_pair(a[0].first + 1, 1));
  long long int curr = 1;
  long long int used = 1;
  for (int i = 1; i < n; i++) {
    int j = a[i].second;
    if (hash.begin()->first <= a[i].first - d) {
      curr = hash.begin()->second;
      hash.erase(hash.begin());
      hash.insert(make_pair(a[i].first + 1, curr));
    } else {
      hash.insert(make_pair(a[i].first + 1, ++used));
      curr = used;
    }
    ans[j] = curr;
  }
  cout << used << endl;
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
  return 0;
}
