| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 44777 | choikiwon | Skyline (IZhO11_skyline) | C++17 | 44 ms | 48880 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;
int N;
int H[302];
int cc[302][202][202];
int dp(int n, int c1, int c2) {
    if(n == N) return 0;
    int &ret = cc[n][c1][c2];
    if(ret != -1) return ret;
    ret = 1e9;
    int add = c1 > c2? (c1 - c2) * 3 : 0;
    c1 = min(c1, c2);
    if(c2 <= H[n + 2]) {
        return ret = add + 7 * c1 + dp(n + 1, c2 - c1, H[n + 2] - c1);
    }
    else {
        if(c1 >= c2 - H[n + 2]) {
            ret = min(ret, add + 5 * (c2 - H[n + 2]) + 7 * (c1 - c2 + H[n + 2]) + dp(n + 1, c2 - c1, c2 - c1));
        }
        ret = min(ret, add + 5 * c1 + dp(n + 1, c2 - c1, H[n + 2]));
        return ret;
    }
}
int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &H[i]);
    }
    memset(cc, -1, sizeof(cc));
    printf("%d", dp(0, H[0], H[1]));
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
