#include <bits/stdc++.h>
using namespace std;
const int NN = 303030;
using pii = pair<int, int>;
using INT = long long;
INT a[NN], ans[NN];
int main() {
  int n, m, d;
  cin >> n >> m >> d;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  multiset<pii> st;
  for (int i = 1; i <= n; i++) st.insert(pii(a[i], i));
  INT day = 1, time = 1;
  while (!st.empty()) {
    auto it = st.lower_bound(pii(time, 0));
    if (it == st.end()) {
      time = 1;
      day++;
      continue;
    }
    time = it->first + d + 1;
    ans[it->second] = day;
    if (st.size() == 1) break;
    if (time > m) {
      time = 1;
      day++;
    }
    st.erase(it);
  }
  cout << day << endl;
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
