Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n, m, k;
- cin >> n >> m >> k;
- int postoecka[m];
- int sakana[n];
- for(int i=0;i<n; i++){
- cin>>sakana[i];
- }
- for(int y=0; y<m;y++){
- cin>>postoecka[y];
- }
- int a=0;
- int b=0;
- int rez=0;
- sort(postoecka, postoecka+m);
- sort (sakana,sakana+n);
- while(a<n and b<m){
- if(postoecka[b]<sakana[a]-k){
- b++;
- }
- else if(postoecka[b]>sakana[a]+k){
- a++;
- }
- else{
- rez++;
- a++;
- b++;
- }
- }
- cout<<rez;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement