#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX;
const long long base = 1e9;
const double PI = acos(-1);
const long long MOD = 1e9 + 7;
const long long N = 1e5 + 10;
void solve();
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
void solve() {
  long long n, m, d;
  cin >> n >> m >> d;
  long long a[n];
  map<long long, long long> pos;
  set<long long> s;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    pos[a[i]] = i;
    s.insert(a[i]);
  }
  long long k = 1, ans[n];
  while (s.size()) {
    auto x = s.begin();
    while (x != s.end()) {
      long long val = *x;
      ans[pos[val]] = k;
      s.erase(x);
      x = s.upper_bound(val + d);
    }
    ++k;
  }
  cout << --k << "\n";
  for (long long i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }
  cout << "\n";
  return;
}
