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>
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 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... |