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];
- vector<int> brojac(150, 0);
- for(int i = 0; i < n; i++) {
- cin >> maski[i];
- brojac[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;
- cout << najmal << " " << najgolem << endl;
- int tmp = 0;
- for(int j = max(najmal, 0); j<= najgolem; j++) {
- tmp += brojac[j];
- }
- rezultat = max(rezultat, tmp);
- }
- cout << rezultat << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement