#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  int N, M, D;
  cin >> N >> M >> D;
  int ans[N], A[N];
  unordered_map<int, int> um;
  set<int> st;
  for (int i = 0; i < (N); i++) {
    cin >> A[i];
    st.insert(A[i]);
    um[A[i]] = i;
  }
  int cnt = 0;
  while (st.size()) {
    cnt++;
    int pos = um[*st.begin()];
    ans[pos] = cnt;
    st.erase(st.begin());
    while (1) {
      auto it = st.lower_bound(A[pos] + 1 + D);
      if (it == st.end()) break;
      pos = um[*it];
      st.erase(it);
      ans[pos] = cnt;
    }
  }
  cout << cnt << endl;
  for (int i = 0; i < (N - 1); i++) cout << ans[i] << " ";
  cout << ans[N - 1] << endl;
  return 0;
}
