#include <bits/stdc++.h>
using namespace std;
bool isFile = 0;
const long long INF = 1e9 + 1234;
const int N = 4e5 + 1234;
const long long MOD = 998244353;
const long long mod = 1e9 + 7;
double EPS = 3e-18;
const double PI = acos(-1);
void faster() {
  if (isFile) {
    freopen(
        ""
        ".in",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void solve() {
  int n, m, d;
  cin >> n >> m >> d;
  vector<long long> a(n);
  vector<long long> b(n);
  map<long long, long long> c;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int p = upper_bound(b.begin(), b.end(), b[i] + d) - b.begin();
    ans = max(ans, p - i);
  }
  c[b[0]] = 1;
  for (int i = 1; i < n; i++) {
    if (b[i] - b[i - 1] <= d) {
      c[b[i]] = c[b[i - 1]] + 1;
      if (c[b[i]] > ans) c[b[i]] = 1;
    } else
      c[b[i]] = c[b[i - 1]];
  }
  cout << ans;
  cout << "\n";
  for (int i = 0; i < n; i++) cout << c[a[i]] << ' ';
}
int main() {
  faster();
  int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
