#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, d, c = 0, i, temp, k;
  cin >> n >> m >> d;
  map<int, int> a;
  vector<int> v(n, 0);
  for (i = 0; i < n; i++) {
    cin >> temp;
    a[temp] = i;
  }
  auto it = a.begin();
  while (it != a.end()) {
    c++;
    v[it->second] = c;
    k = it->first;
    a.erase(it->first);
    while (1) {
      it = a.upper_bound(d + k);
      if (it != a.end()) {
        v[it->second] = c;
        k = it->first;
        a.erase(it->first);
      } else {
        it = a.begin();
        break;
      }
    }
  }
  cout << c << endl;
  for (auto x : v) cout << x << " ";
  return 0;
}
