We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<bits/stdc++.h>#define int long longusingnamespacestd;floatmedian(vector<int>&a,intd){floatmedian;if(d%2==0){intm1=d/2-1;median=(a[m1]+a[m1+1]);}else{median=a[d/2]*2;}returnmedian;}signedmain(){intn,d;intcnt=0;cin>>n>>d;vector<int>a(d);vector<int>mark(n+1);for(inti=0;i<d;i++){cin>>a[i];mark[i]=a[i];}sort(a.begin(),a.end());for(inti=d;i<n;i++){inttemp;cin>>temp;mark[i]=temp;floatme=median(a,d);if(temp>=me)cnt++;autoit=lower_bound(a.begin(),a.end(),mark[i-d]);a.erase(it);autom=lower_bound(a.begin(),a.end(),temp);a.insert(m,temp);}cout<<cnt;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Fraudulent Activity Notifications
You are viewing a single comment's thread. Return to all comments →