#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, d;
set<pair<int, int>> s;
int a[N], ans[N];
void solve() {
  int cnt = 0;
  while (s.size()) {
    ++cnt;
    int pos = s.begin()->second;
    s.erase(s.begin());
    ans[pos] = cnt;
    while (true) {
      auto it = s.lower_bound({a[pos] + d + 1, 0});
      if (it == s.end()) break;
      pos = it->second;
      s.erase(it);
      ans[pos] = cnt;
    }
  }
  cout << *max_element(ans + 1, ans + n + 1) << '\n';
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> d;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    a[i] = x;
    s.insert({x, i});
  }
  solve();
}
