https://cses.fi/problemset/task/1084/
I am stuck on this question…this is my code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n , m , k;
vector<int> a;
vector<int> b;
int i , j;
int l , o;
cin >> n >> m >> k;
for(i = 0 ; i < n ; i++)
{
fin >> l;
a.push_back(l);
}
for(i = 0 ; i < m ; i++)
{
cin >> o;
b.push_back(o);
}
int peoplegothome = 0;
for(i = 0 ; i < a.size() ; i++)
{
for(j = 0; j < b.size() ; j++)
{
if(b[j] >= a[i]-k && b[j] <= a[i]+k || b[j] == a[i]-k && b[j] == a[i]+k)
{
peoplegothome++;
}
else
{
peoplegothome = peoplegothome+0;
}
}
}
cout << peoplegothome;
}