#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void solve() {
  int n, m, d;
  cin >> n >> m >> d;
  int a[n];
  set<pair<int, int>> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s.insert({a[i], i});
  }
  vector<int> ans(n, -1);
  int k = 0;
  while (s.size()) {
    k++;
    int pos = s.begin()->second;
    ans[pos] = k;
    s.erase(s.begin());
    while (1) {
      auto it = s.lower_bound({a[pos] + 1 + d, 0});
      if (it == s.end()) break;
      pos = it->second;
      s.erase(it);
      ans[pos] = k;
    }
  }
  cout << k << "\n";
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
