#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int inf = INT_MAX;
const long long inff = 1e18;
const int mod = 1e9 + 7;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    pq;
long long ans[maxn];
pair<long long, long long> a[maxn];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, d;
  cin >> n >> m >> d;
  for (long long i = 1; i <= n; i++) cin >> a[i].first, a[i].second = i;
  sort(a + 1, a + n + 1);
  long long cnt = 0;
  for (long long i = 1; i <= n; i++) {
    if (pq.empty() || pq.top().first + d + 1 > a[i].first ||
        pq.top().first + d + 1 > m) {
      pq.push(make_pair(a[i].first, ++cnt));
      ans[a[i].second] = cnt;
    } else {
      pair<long long, long long> now = pq.top();
      pq.pop();
      now.first = a[i].first;
      ans[a[i].second] = now.second;
      pq.push(now);
    }
  }
  cout << cnt << endl;
  for (long long i = 1; i <= n; i++) cout << ans[i] << ' ';
}
