#include <bits/stdc++.h>
using namespace std;
struct MyStruct {
  long long val;
  int index;
  int day;
};
bool cmp(const MyStruct &a, const MyStruct &b) { return a.val < b.val; }
int main() {
  int n, m, d;
  cin >> n >> m >> d;
  vector<MyStruct> vec(n);
  set<long long> st;
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &vec[i].val);
    vec[i].index = i;
    st.insert(vec[i].val);
  }
  sort(vec.begin(), vec.end(), cmp);
  vector<MyStruct> ans(n);
  for (int i = 0; i < n; i++) {
    ans[i].val = -1;
  }
  int cur = 0;
  for (int i = 0; i < n; i++) {
    if (ans[i].val != -1) continue;
    cur++;
    int index = i;
    while (ans[index].val == -1 && index < vec.size()) {
      st.erase(vec[index].val);
      ans[index].val = cur;
      ans[index].index = vec[index].index;
      MyStruct p;
      p.val = vec[index].val + d + 1LL;
      set<long long>::iterator pst = st.lower_bound(p.val);
      if (pst == st.end()) {
        break;
      }
      p.val = *pst;
      index = lower_bound(vec.begin(), vec.end(), p, cmp) - vec.begin();
    }
  }
  long long ans_size = (*max_element(ans.begin(), ans.end(), cmp)).val;
  cout << ans_size << endl;
  vector<long long> real_ans(n);
  for (int i = 0; i < n; i++) {
    real_ans[ans[i].index] = ans[i].val;
  }
  for (int i = 0; i < n; i++) {
    cout << real_ans[i] << " ";
  }
}
