Naxocist

Fraudulent Activity Notifications

Apr 28th, 2022
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define INF 1e9
  5.  
  6. using ll = long long;
  7. using pi = pair<int, int>;
  8. using vi = vector<int>;
  9.  
  10. const int N = 205, M = 2e5 + 10;
  11. int counting[N], tmp[M];
  12.  
  13. int main()
  14. {
  15.     ios_base::sync_with_stdio(false); cin.tie(nullptr);
  16.  
  17.     int n, d; cin >> n >> d;
  18.    
  19.     vi v;
  20.     for(int i=0; i<n; ++i) {
  21.         int x; cin >> x;
  22.         v.push_back(x);
  23.     }
  24.  
  25.     int cnt = 0, sz = v.size();
  26.    
  27.     for(int i=0; i<d; ++i) counting[v[i]]++;
  28.    
  29.    
  30.     for(int i=d; i<sz; ++i){
  31.         int x = v[i];
  32.        
  33.         double md;
  34.         int idx=0;
  35.  
  36.         for(int c=0; c<=200; ++c){
  37.             int ct = counting[c];
  38.             while(ct--){
  39.                 tmp[idx++] = c;
  40.                 if(idx > d/2) break;
  41.             }
  42.             if(idx > d/2) break;
  43.         }
  44.        
  45.         md = (d&1 ? tmp[d/2] : (tmp[d/2] + tmp[d/2-1]) / 2.0);
  46.         if(x >= md*2){
  47.             cnt++;
  48.         }
  49.        
  50.         counting[v[i-d]]--;
  51.         counting[v[i]]++;
  52.     }
  53.    
  54.    
  55.     cout << cnt;
  56.     return 0;
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment