| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1109818 | Kirill22 | Skyline (IZhO11_skyline) | C++17 | 47 ms | 760 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
const int N = 201, inf = (int) 1e9;
int dp[2][N][N], cur = 0;
void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dp[cur][i][j] = inf;
        }
    }
    dp[cur][0][0] = 0;
    for (int it = 0; it < n; it++) {
        int h;
        cin >> h;
        cur ^= 1;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dp[cur][i][j] = inf;
            }
        }
        for (int i = 0; i <= h; i++) {
            for (int j = i; j < N; j++) {
                int res = dp[cur ^ 1][i][j] + i * 7;
                // j - i, h - i
                dp[cur][j - i][h - i] = min(dp[cur][j - i][h - i], res);
            }
        }
        for (int i = N - 1; i >= 1; i--) {
            for (int j = N - 1; j >= 1; j--) {
                dp[cur][i - 1][j - 1] = min(dp[cur][i - 1][j - 1], dp[cur][i][j] + 5);
            }
        }
        for (int i = N - 1; i >= 0; i--) {
            for (int j = N - 1; j >= 1; j--) {
                dp[cur][i][j - 1] = min(dp[cur][i][j - 1], dp[cur][i][j] + 3);
            }
        }
    }
    cout << dp[cur][0][0];
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
