제출 #581314

#제출 시각아이디문제언어결과실행 시간메모리
581314alontanayThe short shank; Redemption (BOI21_prison)C++14
15 / 100
211 ms524288 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, d, t; cin >> n >> d >> t; vector<vector<vector<int>>> dp(n+1,vector<vector<int>>(d+1,vector<int>(n+1,1e9))); dp[n] = vector<vector<int>>(d+1,vector<int>(n+1,0)); vector<int> xs(n); for(int &x : xs) { cin >> x; } for(int i = n - 1; i >= 0; i --) { int x = xs[i]; if(x > t) { for(int e = 0; e <= n; e ++) { for(int di = 0; di <= d; di ++) { dp[i][di][e] = dp[i+1][di][e] + (e>i); } } } else { int l = (t-x); int en = min((i + l),n-1); for(int e = 0; e <= n; e ++) { dp[i][0][e] = dp[i+1][0][max(e,en+1)] + 1; } for(int di = 1; di <= d; di ++) { for(int e = 0; e <= n; e ++) { dp[i][di][e] = min(dp[i+1][di-1][0],dp[i+1][di][max(e,en+1)]) + 1; } } } // for(int di = 0; di <= d; di ++) { // for(int e : dp[i][di]) { cout << e << " "; } // cout << "\n"; // } // cout << "~\n"; } cout << dp[0][d][0]; } /* 6 2 5 4 6 4 6 4 6 */
#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...