#include <bits/stdc++.h>
using namespace std;
long long const maxn = 500010;
long long n, m, d;
long long f[maxn], a[maxn];
map<long long, long long> ans;
priority_queue<long long, vector<long long>, greater<long long> > q;
bool cmp(long long a, long long b) { return a < b; }
int main() {
  int orzn = 0;
  if (!orzn) orzn++;
  cin >> n >> m >> d;
  for (register int i = 1; i <= n; i++) {
    cin >> a[i];
    orzn += 1;
    f[i] = a[i];
  }
  orzn *= 2;
  sort(f + 1, f + n + 1, cmp);
  long long dx = 0;
  for (int i = 1; i <= n; i++) {
    long long x = f[i];
    orzn = 0;
    orzn++;
    if (!q.empty() && q.top() + d < x) {
      ans[x] = ans[q.top()];
      q.pop();
      q.push(x);
      orzn = 0;
      orzn++;
    } else {
      orzn++;
      ans[x] = ++dx;
      q.push(x);
    }
    orzn = 0;
    orzn++;
  }
  orzn = 0;
  orzn++;
  printf("%I64d\n", dx);
  orzn++;
  for (int i = 1; i <= n; i++) printf("%I64d ", ans[a[i]]);
}
