Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define T ll rrr;cin>>rrr;for(ll w1=0;w1<rrr;w1++)
- #define cin(vec,a) for(ll i=0;i<a && cin >> vec[i];i++)
- #define cout(vec,a) for(ll i=0;i<a && cout << vec[i];i++)
- #define MOD 1000000007
- #define PI 3.14159265
- #define ceil(a, b) ((a / b) + (a % b ? 1 : 0))
- #define all(v) v.begin(),v.end()
- #define rall(v) v.rbegin(),v.rend()
- typedef long long ll;
- using namespace std;
- void sasa()
- {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- }
- // 20 21 31 35 39 41 49 74 86 90
- // 4 7 14 24 24 60 82 85 85 95
- void solve()
- {
- ll n,m,k;
- cin >> n >> m >> k;
- vector<ll>vec1(n);
- vector<ll>vec2(m);
- cin(vec1,n);
- cin(vec2,m);
- ll l=0,r=0,counter=0;
- sort(all(vec1));
- sort(all(vec2));
- while(l<m)
- {
- if(vec1[r] >= vec2[l]-k && vec1[r] <= vec2[l]+k)l++,counter++,r++;
- else
- {
- if(vec1[r]> vec2[l]+k)l++;
- else r++;
- }
- }
- cout << counter;
- }
- int main()
- {
- sasa();
- ll t = 1;
- //cin >> t;
- while (t--)
- {
- solve();
- if(!t) break;
- cout << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement