#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846264338327950288419716939937510;
const double E = 2.7182818284590452353602874713526624977572470936999596;
const double eps = 0.000000001;
inline int max(int u, int v) { return u > v ? u : v; }
inline int min(int u, int v) { return u < v ? u : v; }
inline long long gcd(long long u, long long v) { return v ? gcd(v, u % v) : u; }
template <typename T>
inline void read(T& u) {
  char id;
  u = 0;
  bool flag = 0;
  id = getchar();
  while (id > '9' || id < '0') {
    if (id == '-') flag = 1;
    id = getchar();
  }
  while ((id <= '9' && id >= '0')) {
    u = u * 10 + id - '0';
    id = getchar();
  }
  if (flag) u *= -1;
}
template <typename T>
inline void read(T& u, T& v) {
  read(u);
  read(v);
}
template <typename T>
inline void read(T& u, T& v, T& tmp) {
  read(u);
  read(v);
  read(tmp);
}
int ass[500100], num[500100], ans[500100];
multiset<pair<int, int> > fuck;
inline bool cmp(int x, int y) { return (num[x] < num[y]); }
int main() {
  int n, m, d;
  read(n, m, d);
  for (int i = (1); (i) <= (n); (i)++) read(num[i]);
  for (int i = (1); (i) <= (n); (i)++) ass[i] = i;
  sort(ass + 1, ass + n + 1, cmp);
  int cnt = 0;
  for (int i = (1); (i) <= (n); (i)++) {
    if (fuck.empty() || num[ass[i]] - (*fuck.begin()).first <= d) {
      fuck.insert(make_pair(num[ass[i]], ++cnt));
      ans[ass[i]] = cnt;
    } else {
      pair<int, int> tmp = *fuck.begin();
      ans[ass[i]] = tmp.second;
      fuck.erase(fuck.begin());
      fuck.insert(make_pair(num[ass[i]], ans[ass[i]]));
    }
  }
  printf("%d\n", cnt);
  for (int i = (1); (i) <= (n); (i)++) printf("%d ", ans[i]);
  return 0;
}
