#include <bits/stdc++.h>
using namespace std;
set<long long> arr;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, d;
  cin >> n >> m >> d;
  long long arr1[n];
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    arr1[i] = x;
    arr.insert(x);
  }
  long long day = 1;
  map<long long, long long> ma;
  set<long long>::iterator f;
  long long cur;
  while (arr.size() != 0) {
    cur = *(arr.begin());
    ma[cur] = day;
    arr.erase(arr.begin());
    while (true) {
      f = arr.lower_bound(cur + d + 1);
      if (f == arr.end()) break;
      cur = *f;
      arr.erase(f);
      ma[cur] = day;
    }
    day++;
  }
  long long mx = LONG_MIN;
  for (long long i = 0; i < n; i++) {
    mx = max(mx, ma[arr1[i]]);
  }
  cout << mx << "\n";
  for (long long i = 0; i < n; i++) {
    cout << ma[arr1[i]] << " ";
  }
  return 0;
}
