#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, d;
  cin >> n >> m >> d;
  set<pair<int, int>> a;
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    a.insert({k, i});
  }
  int i = 1;
  while (!a.empty()) {
    int t = a.begin()->first;
    ans[a.begin()->second] = i;
    a.erase(a.begin());
    while (1) {
      auto it = a.lower_bound({t + d + 1, 0});
      if (it == a.end()) break;
      t = it->first;
      ans[it->second] = i;
      a.erase(it);
    }
    i++;
  }
  cout << i - 1 << endl;
  for (auto k : ans) cout << k << " ";
}
