Advertisement
Josif_tepe

Untitled

Oct 3rd, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <fstream>
  5. #include <cmath>
  6. using namespace std;
  7.  
  8. int main() {
  9.     int n;
  10.     cin >> n;
  11.     int maski[n];
  12.     vector<int> brojac(150, 0);
  13.     for(int i = 0; i < n; i++) {
  14.         cin >> maski[i];
  15.         brojac[maski[i]]++;
  16.     }
  17.     sort(maski, maski + n);
  18.  
  19.     int m;
  20.     cin >> m;
  21.     int zenski[m];
  22.     for(int i = 0; i < m; i++) {
  23.         cin >> zenski[i];
  24.     }
  25.     sort(zenski, zenski + m);
  26.  
  27.     int razlika, K;
  28.     cin >> razlika >> K;
  29.     int rezultat = 0;
  30.     for(int i = 0; i + K - 1 < m; i++) {
  31.         int najgolem = zenski[i] + razlika;
  32.         int najmal = zenski[i + K - 1] - razlika;
  33.         cout << najmal << " " << najgolem << endl;
  34.         int tmp = 0;
  35.         for(int j = max(najmal, 0); j<= najgolem; j++) {
  36.             tmp += brojac[j];
  37.         }
  38.         rezultat = max(rezultat, tmp);
  39.     }
  40.     cout << rezultat << endl;
  41.     return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement