#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, d;
  cin >> n >> m >> d;
  long long x, y, z, i, j, c = 1;
  map<long long, long long> mp, mp2;
  set<long long> st;
  vector<long long> v;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
    st.insert(x);
  }
  for (auto i : st) {
    if (mp[i] == 0) {
      y = i;
      mp[y] = 1;
      mp2[y] = c;
      while (st.upper_bound(y + d) != st.end()) {
        auto it = st.upper_bound(y + d);
        if (mp[*it] == 0) {
          mp[*it] = 1;
          mp2[*it] = c;
        }
        y = *it;
        st.erase(it);
      }
      c++;
    }
  }
  cout << c - 1 << endl;
  for (i = 0; i < n; i++) {
    cout << mp2[v[i]] << " ";
  }
}
