제출 #1021652

#제출 시각아이디문제언어결과실행 시간메모리
102165212345678The short shank; Redemption (BOI21_prison)C++17
15 / 100
68 ms9444 KiB
#include <bits/stdc++.h> using namespace std; const int nx=505; int n, d, T, dp[nx][nx], c[nx][nx], t[nx], lst; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>d>>T; for (int i=1; i<=n; i++) cin>>t[i]; for (int i=0; i<=n; i++) for (int j=0; j<=n; j++) dp[i][j]=1e9; dp[0][0]=0; for (int i=1; i<=n; i++) { int cnt=0, lst=1e9; for (int j=i; j<=n; j++) lst=min(lst+1, t[j]), cnt+=(lst<=T), c[i][j]=cnt; } //cout<<"cost "<<c[3][3]<<'\n'; for (int i=1; i<=n; i++) { for (int j=1; j<=i; j++) for (int k=0; k<i; k++) dp[i][j]=min(dp[i][j], dp[k][j-1]+c[k+1][i]); //for (int j=1; j<=i; j++) cout<<i<<' '<<j<<' '<<dp[i][j]<<'\n'; } cout<<dp[n][d+1]; }
#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...