Josif_tepe

Untitled

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