#include <bits/stdc++.h>
using namespace std;
using namespace std;
struct A {
  int i;
  int j;
} a[200005];
struct rule {
  int operator()(A a, A b) { return a.i < b.i; }
};
set<A, rule> s;
int b[200005];
int main() {
  memset(b, 0, sizeof(b));
  int n, m, d;
  cin >> n >> m >> d;
  for (int i = 0; i < n; i++) cin >> a[i].i, a[i].j = i, s.insert(a[i]);
  int day = 1;
  while (!s.empty()) {
    A y = {0, 0};
    y = *s.upper_bound(y);
    s.erase(y);
    b[y.j] = day;
    int p = m;
    while (1) {
      int t = y.i;
      y.i += d;
      if (s.upper_bound(y) != s.end()) {
        y = *s.upper_bound(y);
        s.erase(y);
        p = p - (y.i - t) + 1;
        b[y.j] = day;
        if (p <= 0) break;
      } else
        break;
    }
    day++;
  }
  cout << day - 1 << endl;
  for (int i = 0; i < n; i++) cout << b[i] << ' ';
  cout << endl;
  return 0;
}
