#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
int n, t, d;
pair<int, int> a[200005];
set<pair<int, int>> s;
int b[200005];
int cnt = 0;
int main() {
  cin >> n >> t >> d;
  d++;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  s.emplace(a[1].first, 1);
  b[a[1].second] = ++cnt;
  for (int i = 2; i <= n; i++) {
    auto it = s.begin();
    if (it->first + d <= a[i].first) {
      b[a[i].second] = it->second;
      s.erase(*it);
      s.emplace(a[i].first, b[a[i].second]);
    } else {
      b[a[i].second] = ++cnt;
      s.emplace(a[i].first, b[a[i].second]);
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++) {
    if (i > 1) putchar(' ');
    printf("%d", b[i]);
  }
  putchar('\n');
  return 0;
}
