#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1123456;
const int MAXINT = 2147483098;
const long long MAXLL = 9223372036854775258LL;
set<pair<int, int> > s;
int ans[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, d, pos = 0, mx = 0;
  cin >> n >> m >> d;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    s.insert(make_pair(a, i));
  }
  for (int i = 1; i <= n; ++i) {
    if (!s.size()) break;
    ans[s.begin()->second] = i;
    mx = i;
    long long val = s.begin()->first;
    s.erase(s.begin());
    while (1) {
      if (!s.size()) break;
      auto it = s.lower_bound(make_pair(val + d + 1, 0LL));
      if (it == s.end()) break;
      ans[it->second] = i;
      val = it->first;
      s.erase(it);
    }
  }
  cout << mx << '\n';
  for (int i = 1; i <= n; ++i) cout << ans[i] << " ";
  return 0;
}
