Submission #523382

#TimeUsernameProblemLanguageResultExecution timeMemory
523382PetySkyline (IZhO11_skyline)C++14
0 / 100
39 ms48204 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int INF = 1e9; const int MOD = 1e9 + 7; int n, v[302], dp[302][202][202]; int main () { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 1; i <= 300; i++) for (int j = 0; j <= 200; j++) for (int k = 0; k <= 200; k++) dp[i][j][k] = INF; for (int i = 0; i <= v[1]; i++) dp[2][v[2]][i] = dp[1][i][0] = 3 * (v[1] - i); for (int i = 2; i <= n; i++) { for (int j = v[i]; j >= 0; j--) for (int k = v[i - 1]; k >= 0; k--) { dp[i][j][k] = min(dp[i][j + 1][k] + 3, dp[i][j][k]); dp[i][j][k] = min(dp[i][j + 1][k + 1] + 5, dp[i][j][k]); } for (int j = v[i + 1]; j >= 0; j--) for (int k = 0; k <= min(v[i], min(v[i + 1], v[i - 1])); k++) if (k >= j) dp[i + 1][v[i + 1] - j][k - j] = min(dp[i + 1][v[i + 1] - j][k - j], dp[i][k][j] + 7 * j); } cout << dp[n][0][0]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...