#include <bits/stdc++.h>
using namespace std;
const int DIM = 2 * 100001;
struct nr {
  int val, ind;
} mins[DIM];
int n, m, d;
int used[DIM], afis[DIM];
bool cmp(nr x, nr y) { return x.val < y.val; }
int main() {
  cin >> n >> m >> d;
  for (int i = 1; i <= n; ++i) {
    cin >> mins[i].val;
    mins[i].ind = i;
  }
  sort(mins + 1, mins + n + 1, cmp);
  int point = 1, last = 1;
  afis[mins[point].ind] = 1;
  for (int i = 2; i <= n; ++i) {
    if (mins[point].val + d < mins[i].val) {
      afis[mins[i].ind] = afis[mins[point].ind];
      point++;
    } else {
      afis[mins[i].ind] = ++last;
    }
  }
  cout << last << '\n';
  for (int i = 1; i <= n; ++i) cout << afis[i] << ' ';
  return 0;
}
