#include <bits/stdc++.h>
using namespace std;
pair<int, int> A[200005];
int res[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, d, i, days = 0;
  cin >> n >> m >> d;
  for (i = 0; i < n; i++) {
    cin >> A[i].first;
    A[i].second = i;
  }
  sort(A, A + n);
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      q;
  for (i = 0; i < n; i++) {
    if (!q.empty() and A[i].first - q.top().first - 1 >= d) {
      q.push({A[i].first, q.top().second});
      res[A[i].second] = q.top().second;
      q.pop();
    } else {
      q.push({A[i].first, ++days});
      res[A[i].second] = days;
    }
  }
  cout << days << '\n';
  for (i = 0; i < n; i++) cout << res[i] << " ";
  return 0;
}
