Problem Statement
Apartments
Implementation
void solve() {
ll n, m, k;
cin >> n >> m >> k;
vll a(n);
multiset<ll> b;
rep(i, n) cin >> a[i];
sort(all(a));
rep(i, m) {
ll x;
cin >> x;
b.insert(x);
}
ll ans = 0;
rep(i, n) {
ll x = a[i] - k;
auto it = b.lower_bound(x);
if (it != b.end()) {
if (*it <= a[i] + k) {
ans++;
b.erase(it);
}
}
}
cout << ans << "\n";
}