#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
int n, m, d;
pair<long long, long long> a[N];
deque<pair<long long, long long> > D;
int res;
int ans[N];
void Input() {
  cin >> n >> m >> d;
  for (int i = 1; i <= (int)n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
}
void Process() {
  sort(a + 1, a + 1 + n);
  res = 1;
  int t = 2;
  D.push_back(pair<long long, long long>(a[1].first, 1));
  ans[a[1].second] = 1;
  while (t <= n) {
    if (a[t].first - D.front().first >= d + 1) {
      D.push_back(pair<long long, long long>(a[t].first, D.front().second));
      ans[a[t].second] = D.front().second;
      D.pop_front();
    } else {
      ++res;
      D.push_back(pair<long long, long long>(a[t].first, res));
      ans[a[t].second] = res;
    }
    ++t;
  }
  cout << res << endl;
  for (int i = 1; i <= (int)n; i++) cout << ans[i] << ' ';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Input();
  Process();
}
