#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, d, a[200005], ans[200005], i, val;
  multiset<pair<long long int, long long int> > s;
  cin >> n >> m >> d;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    s.insert({a[i], i});
  }
  long long int days = 1;
  while (!s.empty()) {
    auto it = s.begin();
    val = it->first;
    ans[it->second] = days;
    s.erase(it);
    while (1) {
      auto it2 = s.upper_bound({val + d, n});
      if (it2 == s.end()) break;
      ans[it2->second] = days;
      val = it2->first;
      s.erase(it2);
    }
    days++;
  }
  cout << days - 1 << endl;
  for (i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}
