#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, d;
  cin >> n >> m >> d;
  int a[n];
  map<int, int> arr;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    arr[a[i]];
  }
  queue<int> myQ;
  int ans = 1;
  map<int, int>::iterator it = arr.begin();
  for (; it != arr.end(); it++) {
    if (myQ.empty()) {
      myQ.push(it->first);
      it->second = ans++;
    } else {
      if (myQ.front() + d < it->first) {
        it->second = arr[myQ.front()];
        myQ.pop();
        myQ.push(it->first);
      } else {
        it->second = ans++;
        myQ.push(it->first);
      }
    }
  }
  cout << ans - 1 << endl;
  for (int i = 0; i < n; i++) {
    cout << arr[a[i]] << " ";
  }
  cout << endl;
}
