#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vll = vector<ll>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m, x, md, cdc = 1;
  cin >> n >> m >> md;
  set<pll> d;
  unordered_map<ll, ll> pos;
  vll b, bc;
  for (ll i = 0; i < n; i++) {
    cin >> x;
    b.push_back(x);
  }
  bc = b;
  sort(b.begin(), b.end());
  d.insert(make_pair(b[0], cdc));
  pos[b[0]] = cdc;
  for (ll i = 1; i < n; i++) {
    auto minc = d.begin();
    if (minc->first + md < b[i]) {
      d.insert(make_pair(b[i], minc->second));
      pos[b[i]] = minc->second;
      d.erase(minc);
    } else {
      d.insert(make_pair(b[i], ++cdc));
      pos[b[i]] = cdc;
    }
  }
  cout << cdc << "\n";
  for (auto& bi : bc) {
    cout << pos[bi] << " ";
  }
  cout << "\n";
  return 0;
}
