#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, d;
  cin >> n >> m >> d;
  vector<pair<long long, long long> > a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  vector<long long> ans(n);
  long long id = 1;
  for (long long i = 0; i < n; i++) {
    if (ans[a[i].second] != 0) continue;
    if (ans[a[i].second] == 0) {
      ans[a[i].second] = id;
      id++;
    }
    long long u = a[i].first;
    long long w = ans[a[i].second];
    while (u <= m) {
      u += 1 + d;
      long long l =
          lower_bound(a.begin(), a.end(), make_pair(u, 0LL)) - a.begin();
      if (l < n) {
        while (l < n && ans[a[l].second] != 0) l++;
      }
      if (l < n && ans[a[l].second] == 0) {
        ans[a[l].second] = w;
      }
      if (l == n) break;
      u = a[l].first;
    }
  }
  cout << id - 1 << endl;
  for (auto x : ans) cout << x << " ";
  return 0;
}
