#include <bits/stdc++.h>
using namespace std;
int n, m, d, val, ans[200005];
pair<long long, long long> a[200005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> d;
  for (int i = (1); i <= (n); ++i) cin >> a[i].first, a[i].second = i;
  sort(a + 1, a + n + 1);
  int r = 2;
  for (int i = (1); i <= (n); ++i) {
    if (!ans[a[i].second]) ans[a[i].second] = ++val;
    while (r <= n && a[r].first - a[i].first <= d) ++r;
    if (r <= n) ans[a[r].second] = ans[a[i].second];
    ++r;
  }
  cout << val << '\n';
  for (int i = (1); i <= (n); ++i) cout << ans[i] << ' ';
  return 0;
}
