Submission #957250

#TimeUsernameProblemLanguageResultExecution timeMemory
957250adaawfSkyline (IZhO11_skyline)C++14
100 / 100
116 ms55244 KiB
#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 timeMemoryGrader output
Fetching results...