Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <fstream>
- #include <cmath>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int maski[n];
- for(int i = 0; i < n; i++) {
- cin >> maski[i];
- }
- sort(maski, maski + n);
- int m;
- cin >> m;
- int zenski[m];
- for(int i = 0; i < m; i++) {
- cin >> zenski[i];
- }
- sort(zenski, zenski + m);
- int razlika, K;
- cin >> razlika >> K;
- int rezultat = 0;
- for(int i = 0; i + K - 1 < m; i++) {
- int najgolem = zenski[i] + razlika;
- int najmal = zenski[i + K - 1] - razlika;
- int kolku_maski = 0;
- for(int j = 0; j < n; j++) {
- if(maski[j] >= najmal and maski[j] <= najgolem) {
- kolku_maski++;;
- }
- }
- rezultat = max(rezultat, kolku_maski);
- }
- cout << rezultat << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement