#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200024;
int read() {
  int ret = 0;
  char ch = getchar();
  bool f = 1;
  for (; !isdigit(ch); ch = getchar()) f ^= !(ch ^ '-');
  for (; isdigit(ch); ch = getchar()) ret = (ret << 1) + (ret << 3) + ch - 48;
  return f ? ret : -ret;
}
int ans[MAX_N];
struct node {
  int time, vis, id;
  bool operator<(const node other) const {
    if (vis == other.vis) return time < other.time;
    return vis > other.vis;
  }
} arr[MAX_N];
set<int> st;
map<int, int> mp;
int main() {
  int n, m, d;
  int flag = 0;
  scanf("%d%d%d", &n, &m, &d);
  for (int i = 1; i <= n; ++i) {
    arr[i].time = read();
    st.insert(arr[i].time);
    mp[arr[i].time] = i;
  }
  int day = 1;
  set<int>::iterator it;
  int last;
  int num = st.size();
  while (num) {
    it = st.begin();
    ans[mp[*it]] = day;
    last = *it;
    st.erase(*it);
    num--;
    if (!num) break;
    while (last + d < *st.rbegin()) {
      it = st.upper_bound(last + d);
      last = *it;
      ans[mp[*it]] = day;
      st.erase(*it);
      num--;
      if (!num) {
        flag = 1;
        break;
      }
    }
    day++;
  }
  if (!flag) day++;
  printf("%d\n", day - 1);
  for (int i = 1; i <= n; ++i)
    i == n ? printf("%d\n", ans[i]) : printf("%d ", ans[i]);
  return 0;
}
