#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m, d;
  cin >> n >> m >> d;
  vector<int> arr(n);
  map<int, int> ind;
  set<int> st;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    ind[arr[i]] = i;
    st.insert(arr[i]);
  }
  int lst = 0;
  map<int, int> min_to_day_map;
  while (st.size()) {
    lst++;
    auto it = st.begin();
    int val = *it;
    min_to_day_map[val] = lst;
    st.erase(it);
    do {
      it = st.lower_bound(val + d + 1);
      if (it == st.end()) continue;
      val = *it;
      min_to_day_map[val] = lst;
      st.erase(it);
    } while (it != st.end());
  }
  cout << lst << "\n";
  vector<int> ans(n);
  for (auto pr : min_to_day_map) {
    ans[ind[pr.first]] = pr.second;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
