#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int a[300001];
int b[300001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, d;
  cin >> n >> m >> d;
  set<pair<int, int> > s;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s.insert({a[i], i});
  }
  int day = 0;
  auto f = *s.begin();
  s.erase(f);
  b[f.second] = day;
  while (!s.empty()) {
    if (f.first + d > m) {
      day++;
      f = {-d, -1};
    }
    auto g = s.lower_bound({f.first + d + 1, -1});
    if (g != s.end()) {
      b[g->second] = day;
      f = *g;
      s.erase(g);
    } else {
      day++;
      f = {-d, -1};
    }
  }
  cout << day + 1 << '\n';
  for (int i = 0; i < n; ++i) {
    cout << b[i] + 1 << ' ';
  }
  return 0;
}
