--正文
贪心
排序好慢慢找就好
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL; int a[],b[];
int n,m,x;
int main(){
while (scanf("%d %d %d",&n,&m,&x) != EOF){
int i,j,k;
for (i=;i<=n;i++){
scanf("%d",&a[i]);
}
for (i=;i<=m;i++){
scanf("%d",&b[i]);
}
sort(a+,a++n); sort(b+,b++m);
int nowa = ,nowb = ,total = ;
while (nowa <= n && nowb <= m){
int res = a[nowa] - b[nowb];
if (res<) res = -res;
if (res<=x){
nowa ++; nowb ++; total ++; continue;
}
else {
if (a[nowa] > b[nowb]){
nowb++;
}
else {
nowa++;
}
}
}
printf("%d\n",total);
}
return ;
}