#include <bits/stdc++.h>
using namespace std;
int a[200000], b[200000];
set<pair<int, int>> se;
set<pair<int, int>>::iterator t;
int main() {
  int n, m, d;
  cin >> n >> m >> d;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    se.insert(make_pair(a[i], i));
  }
  int cnt = 0, pos;
  while (!se.empty()) {
    pos = se.begin()->second;
    b[pos] = ++cnt;
    se.erase(se.begin());
    while (1) {
      t = se.lower_bound({a[pos] + d + 1, 0});
      if (t == se.end()) break;
      pos = t->second;
      b[pos] = cnt;
      se.erase(t);
    }
  }
  cout << cnt << "\n" << b[0] << " ";
  for (int i = 1; i < n; i++) cout << b[i] << " ";
  return 0;
}
