Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<algorithm>
- #include<math.h>
- using namespace std;
- int main()
- {
- int n,m,k;
- cin>>n>>m>>k;
- int p[n];
- int a[m];
- for(int i=0;i<n;i++)
- {
- cin>>p[i];
- }
- for(int i=0;i<m;i++)
- {
- cin>>a[i];
- }
- sort(p,p+n);
- sort(a,a+m);
- int i=0;
- int j=0;
- int br=0;
- while(i<n && j<m)
- {
- if(fabs(p[i]-a[j])<=k)
- {
- i++;
- j++;
- br++;
- }else
- {
- if(p[i]>a[j])
- {
- j++;
- }else
- {
- i++;
- }
- }
- }
- cout<<br;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement