#include <bits/stdc++.h>
using namespace std;
const int SZ = 1000010, INF = 0x7FFFFFFF;
const double EPS = 1e-9;
int ans[SZ];
int main() {
  std::ios::sync_with_stdio(0);
  long long n, m, d;
  cin >> n >> m >> d;
  map<long long, long long> st;
  for (int i = 0; i < n; ++i) {
    long long tmp;
    cin >> tmp;
    st.insert(make_pair(tmp, i));
  }
  int res = 0;
  for (int i = 1; !st.empty(); ++i) {
    ++res;
    auto bg = st.begin();
    int a = bg->first, b = bg->second;
    st.erase(bg);
    ans[b] = i;
    for (long long j = a + d + 1; j <= m && !st.empty();) {
      auto cur = st.begin();
      if (st.lower_bound(j) == st.end())
        break;
      else
        cur = st.lower_bound(j);
      ans[cur->second] = i;
      j = cur->first + d + 1;
      st.erase(cur);
    }
  }
  cout << res << endl;
  for (int i = 0; i < n; ++i) {
    if (i != 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
