제출 #581313

#제출 시각아이디문제언어결과실행 시간메모리
581313alontanayThe short shank; Redemption (BOI21_prison)C++14
0 / 100
216 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,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); int sz = en-i+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]; }

컴파일 시 표준 에러 (stderr) 메시지

prison.cpp: In function 'int main()':
prison.cpp:28:17: warning: unused variable 'sz' [-Wunused-variable]
   28 |             int sz = en-i+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...