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>
#define pb push_back
#define ctoi(x) int(x-'0')
#define cdv(x,y) (((x)+(y)-1)/(y))
#define LOOP(n) for(int rp=0;rp<(n);rp++)
using namespace std;
typedef long long ll;
typedef long double dl;
const int SZ=2e5+7;
int l[SZ],n,d,t,a[SZ],f[SZ];
vector<int>v[SZ];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> n >> d >> t;
int ans=0;
for(int i=0;i<n;i++){
cin >> a[i];
l[i]=i;
if(a[i]<=t){
ans++;continue;
}
for(int j=i-1;j>=0;j--){
if(a[j]+i-j>t)continue;
l[i]=j,v[j].pb(i),ans++;
break;
}
for(int j=l[i];j<i;j++)f[j]++;
}
LOOP(d){
int ps=0;
for(int i=1;i<n;i++){
if(f[i]>f[ps])ps=i;
}
if(!f[ps])break;
ans-=f[ps];
for(auto&i:v[ps]){
while(l[i]<i)f[l[i]++]--;
}
}
cout << ans;
return 0;
}
# | 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... |