#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
void test_case() {
  long long n, m, d;
  cin >> n >> m >> d;
  vector<long long> arr(n), ans(n);
  map<long long, long long> mp;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    mp[arr[i]] = i;
  }
  priority_queue<pair<long long, long long> > pq;
  sort(arr.begin(), arr.end());
  pq.push({-arr[0], 1});
  ans[mp[arr[0]]] = 1;
  long long day = 1;
  for (long long i = 1; i < n; i++) {
    auto x = pq.top();
    if (arr[i] + x.first > d) {
      pq.pop();
      pq.push({-arr[i], x.second});
      ans[mp[arr[i]]] = x.second;
    } else {
      pq.push({-arr[i], ++day});
      ans[mp[arr[i]]] = day;
    }
  }
  cout << day << "\n";
  for (long long i = 0; i < n; i++) cout << ans[i] << " ";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) test_case();
}
