# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1106686 | andrewp | The short shank; Redemption (BOI21_prison) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Dedicated to my love, ivaziva
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using pll=pair<int,int>;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define ldb double
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
void rd(int&x){scanf("%i",&x);}
void rd(ll&x){scanf("%lld",&x);}
void rd(char*x){scanf("%s",x);}
void rd(ldb&x){scanf("%lf",&x);}
void rd(string&x){scanf("%s",&x);}
int ri(){int x;rd(x);return x;}
#ifndef ONLINE_JUDGE
#include "C:\Users\andre\Downloads\cpp-dump-0.7.0\cpp-dump-0.7.0\cpp-dump.hpp"
#define dbg(...) cpp_dump(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T1,typename T2>void rd(pair<T1,T2>&x){rd(x.first);rd(x.second);}
template<typename T>void rd(vector<T>&x){for(T&i:x)rd(i);}
template<typename T,typename...A>void rd(T&x,A&...args){rd(x);rd(args...);}
template<typename T>void rd(){T x;rd(x);return x;}
template<typename T>vector<T> rv(int n){vector<T> x(n);rd(x);return x;}
const int N=2e6+50;
int n,d,t,a[N];
int main(){
rd(n,d,t);
for(int i=1;i<=n;i++){
a[i]=ri();
a[i]=(a[i]>=t?0:1);
}
vector<int> v;
bool flag=false;
int curr=0,ans=0;
for(int i=1;i<=n;i++){
if(a[i]){
if(flag&&curr) v.pb(curr);
else ans+=curr;
curr=0;
flag=true;
}else curr++;
}
if(flag&&curr) v.pb(curr);
else ans+=curr;
sort(rall(v));
for(int i=0;i<d;i++) ans+=v[i];
printf("%d\n",n-ans);
return 0;
}