CCCPaste

Untitled

#include 
#include 
#include 
using namespace std;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    int a[n], b[m];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < m; i++) {
        cin >> b[i];
    }
    sort(a, a + n);
    sort(b, b + m);
    int i = 0, j = 0;
    int s = 0;
    while(i < n and j < m) {
        if(abs(a[i] - b[j]) <= k) {
            i++;
            j++;
            s++;
            continue;
        }
        if(a[i] < b[j]) {
            i++;
        }
        else {
            j++;
        }
    }
    cout << s << endl;
    return 0;
}
/*
 
 
 4 3 5
 45 60  60 80
 50 60 75
 **/