Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- vector<int> maski(n);
- for(int i = 0; i < n; i++) {
- cin >> maski[i];
- }
- sort(maski.begin(), maski.end());
- int m;
- cin >> m;
- vector<int> zenski(m);
- for(int i = 0; i < m; i++) {
- cin >> zenski[i];
- }
- sort(zenski.begin(), zenski.end());
- int R, k;
- cin >> R >> k;
- int res = 0;
- for(int i = 0; i < m; i++) {
- if(i + k - 1 < m) {
- int najgolem = zenski[i] + R;
- int najmal = zenski[i + k - 1] - R;
- int idx1 = (int) (upper_bound(maski.begin(), maski.end(), najgolem) - maski.begin());
- int idx2 = (int) (lower_bound(maski.begin(), maski.end(), najmal) - maski.begin());
- res = max(res, (idx1 - idx2));
- }
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement