Josif_tepe

Untitled

Nov 5th, 2025
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. const int maxn = 1e5 + 10;
  7. int n, m;
  8. int maski[maxn], zenski[maxn];
  9. int main()
  10. {
  11.     cin >> n;
  12.    
  13.     vector<int> cnt(200, 0);
  14.     for(int i = 0; i < n; i++) {
  15.         cin >> maski[i];
  16.        
  17.         cnt[maski[i]]++;
  18.     }
  19.    
  20.     cin >> m;
  21.     for(int i = 0; i < m; i++) {
  22.         cin >> zenski[i];
  23.     }
  24.    
  25.     int R, k;
  26.     cin >> R >> k;
  27.     sort(maski, maski + n);
  28.     sort(zenski, zenski + m);
  29.    
  30.    
  31.     int res = 0;
  32.     for(int i = 0, j = k - 1; j < m; i++, j++) {
  33.         int A = zenski[j] - R;
  34.         int B = zenski[i] + R;
  35.        
  36.        
  37.         int c = 0;
  38.         for(int j = A; j <= B; j++) {
  39.             c += cnt[j];
  40.         }
  41.         res = max(res, c);
  42.     }
  43.     cout << res << endl;
  44.    
  45.    
  46.    
  47.      return 0;
  48. }
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment