#include <bits/stdc++.h>
using namespace std;
int main() {
  int(n), (m), (d);
  scanf("%d %d %d", &(n), &(m), &(d));
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i].first);
    v[i].second = i;
  }
  sort((v).begin(), (v).end());
  vector<int> ans(n);
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  int sz = 1;
  pq.push({v[0].first, sz});
  ans[v[0].second] = sz;
  for (int i = 1; i < n; i++) {
    if (v[i].first - pq.top().first > d) {
      int x = pq.top().second;
      pq.pop();
      pq.push({v[i].first, x});
      ans[v[i].second] = x;
    } else {
      sz++;
      pq.push({v[i].first, sz});
      ans[v[i].second] = sz;
    }
  }
  cout << sz << "\n";
  for (int i = 0; i <= ans.size() - 1; i++)
    cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');
  return 0;
}
