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