#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<string>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAX_N = 2e5 + 5;
const int mod = 1e9 + 7;
const ll INF = 1e18;
int arr[MAX_N];
void solve() {
  int n, m, d;
  cin >> n >> m >> d;
  set<pi> s;
  vector<int> ans(n + 1, -1);
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    s.insert(make_pair(arr[i], i));
  }
  int cnt = 0;
  while (!s.empty()) {
    cnt++;
    int idx = s.begin()->second;
    ans[idx] = cnt;
    s.erase(s.begin());
    while (1) {
      auto it = s.lower_bound(make_pair(arr[idx] + 1 + d, 0));
      if (it == s.end()) break;
      idx = it->second;
      ans[idx] = cnt;
      s.erase(it);
    }
  }
  cout << cnt << endl;
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t start = clock();
  solve();
  fprintf(stderr, "Total Time: %.4f\n",
          (double)(clock() - start) / CLOCKS_PER_SEC),
      fflush(stderr);
  return 0;
}
