#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,d,T; cin>>n>>d>>T;
vector<int> v(n); for(int& i : v) cin>>i;
// MATRESSES ONLY CAN BE PLACED between a good and a bad --> covers a segment of just bad, so i place a matress in the ones that "recover" more spits
vector<int> newv(n,0); newv[0] = v[0];
set<int> good;
for(int i = 0; i<n; i++){
if(v[i] <= T) good.insert(i);
}
vector<int> canplace;
for(int i = 1; i<n; i++){
newv[i] = min(newv[i-1]+1,v[i]);
if(v[i] > T && v[i-1] < T){
// TAKE ACTUAL BEST VALUE
int len = *good.lower_bound(i) - i;
len = min(len, T-newv[i-1]);
canplace.push_back(len);
}
}
sort(canplace.begin(),canplace.end());
int sz = canplace.size();
for(int i = 0; i<min(sz,d); i++){
canplace.pop_back();
}
// will revel
int ans = 0;
for(int i : canplace) ans+=i;
ans+=good.size();
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |