#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0},
    dxx[8] = {0, 0, 1, 1, 1, -1, -1, -1}, dyy[8] = {1, -1, 0, 1, -1, 0, 1, -1};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int i;
  long long int n, m, d;
  cin >> n >> m >> d;
  pair<long long int, int> a[n + 5];
  long long int last[n + 5], ans[n + 5];
  for (i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
    last[i + 1] = -1;
  }
  sort(a, a + n);
  int ind = 1;
  ans[a[0].second] = 1;
  deque<long long int> dq;
  dq.push_back(1);
  last[1] = a[0].first;
  int z;
  for (i = 1; i < n; ++i) {
    z = dq.front();
    if (a[i].first - last[z] - 1 >= d) {
      last[z] = a[i].first;
      ans[a[i].second] = z;
      dq.pop_front();
      dq.push_back(z);
    } else {
      last[++ind] = a[i].first;
      ans[a[i].second] = ind;
      dq.push_back(ind);
    }
  }
  cout << ind << "\n";
  for (i = 0; i < n; ++i) cout << ans[i] << " ";
  return 0;
}
