#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigMod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T modInverse(T a, T M) {
  return bigMod(a, M - 2, M);
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  a = abs(a);
  b = abs(b);
  return (a / gcd(a, b)) * b;
}
template <class T>
inline string int2String(T a) {
  ostringstream str;
  str << a;
  return str.str();
}
const int dr[] = {0, 1, 0, -1, -1, 1, 1, -1, -2, -2, 2, 2, -1, -1, 1, 1};
const int dc[] = {1, 0, -1, 0, 1, 1, -1, -1, -1, 1, -1, 1, -2, 2, -2, 2};
void fileIO() {}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  fileIO();
  int start_s = clock();
  long long n, m, d, x;
  scanf("%lld%lld%lld", &n, &m, &d);
  set<pair<long long, long long> > st;
  for (int i = int(0); i < int(n); i++)
    scanf("%lld", &x), st.insert(make_pair(x, i));
  vector<long long> out(n);
  long long day = 0;
  while (!st.empty()) {
    day++;
    long long start = st.begin()->first + d + 1;
    out[st.begin()->second] = day;
    st.erase(st.begin());
    auto it = st.begin();
    while ((it = st.upper_bound(make_pair(start, 0))) != st.end()) {
      while (it != st.end()) {
        if (it->first >= start) {
          out[it->second] = day;
          start = max(start, it->first);
          st.erase(it);
          goto Dwn;
        }
        it++;
      }
      break;
    Dwn:
      start += d + 1;
    }
    if (it == st.end() && !st.empty()) {
      it--;
      if (it->first >= start) {
        out[it->second] = day;
        start = max(start, it->first);
        st.erase(it);
      }
    }
  }
  printf("%lld\n", day);
  for (auto x : out) printf("%lld ", x);
  puts("");
  return 0;
}
