# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
960218 | Isam | Skyline (IZhO11_skyline) | C++17 | 110 ms | 55376 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;
constexpr int inf = 1E9;
int n, h[305], dp[305][205][205];
int f(int i, int x, int y){
if(i == n + 1) return 0;
if(dp[i][x][y]) return dp[i][x][y];
int res = inf;
if(!x) res = f(i + 1, y, h[i+2]);
else{
res = min(res, f(i, x - 1, y) + 3);
if(y){
res = min(res, f(i, x - 1, y - 1) + 5);
if(x <= min(y, h[i + 2])) res = min(res, f(i + 1, y - x, h[i + 2] - x) + 7 * x);
}
}
return dp[i][x][y] = res;
}
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
register int j(1);
loop:
cin >> h[j++];
if(j <= n) goto loop;
cout << f(1, h[1], h[2]) << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |