Submission #867172

#TimeUsernameProblemLanguageResultExecution timeMemory
867172Yahia_EmaraThe short shank; Redemption (BOI21_prison)C++17
0 / 100
1496 ms20076 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]; 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 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...