# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957250 | adaawf | Skyline (IZhO11_skyline) | C++14 | 116 ms | 55244 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 <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 |
---|---|---|---|---|
Fetching results... |