#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, d;
  cin >> n >> m >> d;
  vector<long long> v(n);
  unordered_map<long long, long long> mp;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]] = i;
  }
  sort(v.begin(), v.end());
  vector<long long> ans(n);
  long long c = 1;
  for (int i = 0; i < n; i++) {
    if (ans[i]) continue;
    ans[i] = c;
    int j = v[i];
    int curr = 0;
    while (j <= m) {
      auto it = upper_bound(v.begin() + curr, v.end(), j + d) - v.begin();
      if (it == n) break;
      if (ans[it]) {
        curr = it + 1;
        continue;
      } else
        curr = 0;
      ans[it] = c;
      j = v[it];
    }
    c++;
  }
  cout << c - 1 << endl;
  vector<long long> final(n);
  for (int i = 0; i < n; i++) {
    final[mp[v[i]]] = ans[i];
  }
  for (auto i : final) cout << i << " ";
  return 0;
}
