Submission #867177

#TimeUsernameProblemLanguageResultExecution timeMemory
867177Yahia_EmaraThe short shank; Redemption (BOI21_prison)C++17
35 / 100
1287 ms524288 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...