Submission #957250

# Submission time Handle Problem Language Result Execution time Memory
957250 2024-04-03T10:14:34 Z adaawf Skyline (IZhO11_skyline) C++14
100 / 100
116 ms 55244 KB
#include <iostream>
using namespace std;
int n, f[305][205][205], a[305];
int trya(int i, int x, int y) {
    if (i == n + 1) return 0;
    if (f[i][x][y] != 0) return f[i][x][y];
    int res = 1e9;
    if (x == 0) res = trya(i + 1, y, a[i + 2]);
    else {
        res = min(res, trya(i, x - 1, y) + 3);
        if (y != 0) {
            res = min(res, trya(i, x - 1, y - 1) + 5);
            if (x <= min(y, a[i + 2])) res = min(res, trya(i + 1, y - x, a[i + 2] - x) + x * 7);
        }
    }
    f[i][x][y] = res;
    return res;
}
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    cout << trya(1, a[1], a[2]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 3 ms 2652 KB Output is correct
11 Correct 13 ms 13144 KB Output is correct
12 Correct 4 ms 3420 KB Output is correct
13 Correct 16 ms 14736 KB Output is correct
14 Correct 23 ms 20308 KB Output is correct
15 Correct 73 ms 43348 KB Output is correct
16 Correct 68 ms 40144 KB Output is correct
17 Correct 116 ms 55244 KB Output is correct
18 Correct 104 ms 54020 KB Output is correct
19 Correct 102 ms 51024 KB Output is correct
20 Correct 104 ms 55120 KB Output is correct