Submission #963213

# Submission time Handle Problem Language Result Execution time Memory
963213 2024-04-14T18:20:45 Z biank Skyline (IZhO11_skyline) C++14
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 300;

using ll = long long;

const ll INF = 1e18;

ll dp[MAX_N][MAX_N][MAX_N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n;
    cin >> n;
    vector<int> h(n + 2);
    for (int i = 2; i <= n + 1; i++) {
        cin >> h[i];
    }
    for (int i = 2; i <= n + 1; i++) {
        for (int j = 0; j <= h[i - 1]; j++) {
            for (int k = 0; k <= h[i]; k++) {
                dp[i][j][k] = INF;
                if (k != 0) dp[i][j][k] = min(dp[i][j][k], dp[i][j][k - 1] + 3LL);
                if (j != 0 && k != 0) dp[i][j][k] = min(dp[i][j][k], dp[i][j - 1][k - 1] + 5LL);
                if (j >= k) dp[i][j][k] = min(dp[i][j][k], dp[i - 1][h[i - 2] - k][j - k] + 7LL * k);
            }
        }
    }
    cout << dp[n + 1][h[n]][h[n + 1]] << '\n';
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -