#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
set<pair<int, int> > q;
int ar[N];
int ans[N];
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, d;
  cin >> n >> m >> d;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
    q.insert({ar[i], i});
  }
  int cnt = 0;
  while (!q.empty()) {
    cnt++;
    int p = q.begin()->second;
    ans[p] = cnt;
    q.erase(q.begin());
    while (true) {
      auto it = q.lower_bound({ar[p] + 1 + d, 0});
      if (it == q.end()) break;
      p = it->second;
      q.erase(it);
      ans[p] = cnt;
    }
  }
  cout << cnt << "\n";
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
