#include <bits/stdc++.h>
using namespace std;
using INT = long long;
using pii = pair<int, int>;
int a[200100], ans[200100];
pii p[200100];
int main() {
  int n, m, d;
  cin >> n >> m >> d;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) p[i] = pii(a[i], i);
  sort(p + 1, p + n + 1);
  ans[p[1].second] = 1;
  set<pii> s;
  s.insert(p[1]);
  for (int i = 2; i <= n; i++) {
    auto q = *s.begin();
    int u = q.first;
    if (u + d >= p[i].first) {
      ans[p[i].second] = s.size() + 1;
      s.insert(p[i]);
      continue;
    }
    s.erase(q);
    ans[p[i].second] = ans[q.second];
    s.insert(p[i]);
  }
  cout << s.size() << endl;
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  cout << endl;
}
