#include <bits/stdc++.h>
using namespace std;
const int oo = 1000000007;
const int nn = 200010;
int n, m, d, ans[nn], nxt[nn];
pair<int, int> a[nn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> d;
  for (int i = 1, _key = n; i <= _key; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  int p = 1;
  for (int i = 1, _key = n; i <= _key; ++i) {
    while (p <= n && a[p].first - a[i].first <= d) p++;
    nxt[i] = p;
    p++;
  }
  int cnt = 0;
  for (int i = 1, _key = n; i <= _key; ++i)
    if (!ans[a[i].second]) {
      cnt++;
      for (int j = i; j <= n; j = nxt[j]) ans[a[j].second] = cnt;
    }
  cout << cnt << "\n";
  for (int i = 1, _key = n; i <= _key; ++i) cout << ans[i] << " ";
}
