Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int n, m;
- cin >> n;
- int maski[n];
- vector<int> brojac(200, 0);
- vector<int> pref_sum(200, 0);
- int y = 0;
- for(int i = 0; i < n; i++){
- cin >> maski[i];
- brojac[maski[i]]++;
- }
- for(int i = 0; i <= 90; i++) {
- y += brojac[i];
- pref_sum[i] = y;
- }
- cin >> m;
- int zenski[m];
- for(int i = 0; i < m; i++){
- cin >> zenski[i];
- }
- int k, r;
- cin >> r >> k;
- sort(zenski, zenski + m);
- int L = 0;
- int R = k - 1;
- int s = 0;
- for(int i = k - 1; i < m; i++){
- int temp = 0;
- int minimum = zenski[R] - r;
- int maksimum = zenski[L] + r;
- temp = pref_sum[maksimum] - pref_sum[max(minimum - 1, 0)];
- if(temp > s){
- s = temp;
- }
- L++;
- R++;
- }
- cout << s << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement