| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 549971 | colossal_pepe | 스카이라인 (IZhO11_skyline) | C++17 | 2096 ms | 47964 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstring>
using namespace std;
/*
dp[i][carry][carry, pass forward] = min cost for range [i...n]
*/
const int INF = 1e9;
int n, h[301], dp[301][201][201];
int brutus(int i, int c1, int c2) {
if (i >= n) return 0;
if (dp[i][c1][c2] != -1) return dp[i][c1][c2];
int h_cur = h[i] - c1 - c2;
dp[i][c1][c2] = INF;
for (int cnt3 = 0; cnt3 <= h_cur; cnt3++) {
for (int cnt2 = 0; cnt2 <= h_cur - cnt3; cnt2++) {
dp[i][c1][c2] = min(dp[i][c1][c2], brutus(i + 1, c2 + cnt2, cnt3) + 7 * cnt3 + 5 * cnt2 + 3 * (h_cur - cnt3 - cnt2));
}
}
return dp[i][c1][c2];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(dp, -1, sizeof(dp));
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
}
cout << brutus(0, 0, 0) << '\n';
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
