#include <bits/stdc++.h>
using namespace std;
const long long M = 998244353;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, m, d;
  cin >> n >> m >> d;
  long long a[n];
  set<pair<long long, long long> > st;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    st.insert({a[i], i});
  }
  long long day = 0;
  while (!st.empty()) {
    day++;
    long long cur = 0;
    while (true) {
      auto it = st.lower_bound({cur + 1, 0});
      if (it == st.end()) break;
      a[it->second] = day;
      cur = it->first + d;
      st.erase(it);
    }
  }
  cout << day << '\n';
  for (long long i = 0; i < n; i++) cout << a[i] << " ";
}
