#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int index, value, re;
};
bool SS1(node &a, node &b) { return a.value < b.value; }
bool SS2(node &a, node &b) { return a.index < b.index; }
vector<node> w;
vector<bool> used;
long long int n, m, d;
void enter() {
  cin >> n >> m >> d;
  for (int i = 0; i < n; i++) {
    node t;
    cin >> t.value;
    t.index = i;
    t.re = 0;
    w.push_back(t);
    used.push_back(false);
  }
  sort(w.begin(), w.end(), SS1);
}
void solve() {
  vector<long long int> temp;
  for (int i = 0; i < n; i++) {
    temp.push_back(w[i].value);
  }
  int day = 1;
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      w[i].re = day;
      long long int t = w[i].value;
      while (t + (d + 1) <= m) {
        vector<long long int>::iterator up;
        up = upper_bound(temp.begin(), temp.end(), t + d);
        if (up != temp.end()) {
          if (used[up - temp.begin()]) {
            int pos = up - temp.begin();
            while (pos < n && used[pos]) pos++;
            if (pos == n)
              break;
            else {
              t = temp[pos];
              used[pos] = true;
              w[pos].re = day;
            }
          } else {
            t = *up;
            used[up - temp.begin()] = true;
            w[up - temp.begin()].re = day;
          }
        } else
          break;
      }
      day++;
    }
  }
  sort(w.begin(), w.end(), SS2);
  cout << day - 1 << endl;
  for (int i = 0; i < n; i++) cout << w[i].re << " ";
  cout << endl;
}
int main() {
  enter();
  solve();
  return 0;
}
