Submission #429779

#TimeUsernameProblemLanguageResultExecution timeMemory
429779mosiashvililukaThe short shank; Redemption (BOI21_prison)C++14
15 / 100
2086 ms39364 KiB
#include<bits/stdc++.h> using namespace std; long long a,b,c,d,e,i,j,ii,jj,zx,xc,k,T,f[2000009]; vector <long long> dp[500009]; int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>a>>k>>T; for(i=1; i<=a; i++){ cin>>f[i]; } for(i=0; i<=a+1; i++){ dp[i].resize(k+3); } for(i=0; i<=a+1; i++){ for(j=0; j<=k+1; j++){ dp[i][j]=a+3; } } for(i=1; i<=a; i++){ zx=0;c=f[i]; for(ii=i; ii<=a; ii++){ xc=(min(f[ii],c+1)<=T); zx+=xc; c=min(f[ii],c+1); } dp[i][0]=zx; } dp[a+1][0]=0; for(i=a; i>=1; i--){ for(j=1; j<=k; j++){ zx=0;c=f[i]; for(ii=i; ii<=a; ii++){ xc=(min(f[ii],c+1)<=T); zx+=xc; e=dp[ii+1][j-1]+zx; if(dp[i][j]>e) dp[i][j]=e; c=min(c+1,f[ii]); } } } cout<<dp[1][k]; 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...