# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169602 | 2019-12-21T11:40:53 Z | SamAnd | Skyline (IZhO11_skyline) | C++17 | 3 ms | 1400 KB |
#include <bits/stdc++.h> using namespace std; const int N = 303, INF = 1000000009; int n; int a[N]; int dp[N][N][N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); if (n == 1) { printf("%d\n", a[1] * 3); return 0; } for (int i = 0; i <= n; ++i) { for (int j = 0; j < N; ++j) { for (int k = 0; k < N; ++k) { dp[i][j][k] = INF; } } } dp[2][a[1]][a[2]] = 0; for (int i = 2; i <= n; ++i) { for (int j = N - 1; j >= 0; --j) { for (int k = N - 1; k >= 0; --k) { if (k > 0) dp[i][j][k - 1] = min(dp[i][j][k - 1], dp[i][j][k] + 3); if (k > 0 && j > 0) dp[i][j - 1][k - 1] = min(dp[i][j - 1][k - 1], dp[i][j][k] + 5); } } if (i == n) break; for (int j = 0; j < N; ++j) { for (int k = 0; k < N; ++k) { if (a[i + 1] >= j && k >= j) { dp[i + 1][k - j][a[i + 1] - j] = min(dp[i + 1][k - j][a[i + 1] - j], dp[i][j][k] + j * 7); } } } } printf("%d\n", dp[n][0][0]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Incorrect | 3 ms | 1400 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |