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],w[SZ];
set<int>st;
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++,st.insert(i);
w[min(n,i+t-a[i])].pb(i);
}
else if(!st.empty()){
ans++;
l[i]=*(--st.end());
for(int j=l[i];j<i;j++)f[j]++,v[j].pb(i);
}
for(auto&j:w[i])st.erase(st.find(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... |