#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, m, d;
  cin >> n >> m >> d;
  multiset<long long> all;
  map<long long, long long> smth;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    all.insert(x);
    smth[x] = i;
  }
  long long shag = 1;
  vector<long long> ans(n);
  while (all.size() > 0) {
    long long now = *all.begin();
    bool fl = false;
    while (all.upper_bound(now + d) != all.end()) {
      all.erase(now);
      ans[smth[now]] = shag;
      now = *all.upper_bound(now + d);
      fl = true;
    }
    if (true) {
      ans[smth[now]] = shag;
      all.erase(now);
    }
    shag++;
  }
  cout << shag - 1 << "\n";
  for (auto elem : ans) cout << elem << " ";
  cout << "\n";
  return 0;
}
