# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1045472 | pcc | The short shank; Redemption (BOI21_prison) | C++17 | 34 ms | 4568 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.
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fs first
#define sc second
const int mxn = 2e6+10;
int N,D,T;
vector<int> seq[3];
vector<pii> v;
int arr[mxn];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>D>>T;
int ans = N;
for(int i = 1;i<=N;i++){
cin>>arr[i];
if(arr[i]<=T)continue;
if(v.empty()||v.back().sc != i-1)v.push_back(pii(i,i));
else v.back().sc++;
}
for(auto &[s,e]:v){
int c = 1;
if(s == 1)c--;
seq[c].push_back(e-s+1);
}
for(auto &i:seq)sort(i.rbegin(),i.rend());
for(int i = 0;i<D&&i<seq[1].size();i++)ans -= seq[1][i];
for(auto &i:seq[0])ans -= i;
cout<<ans<<'\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |