# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85884 | farukkastamonuda | Skyline (IZhO11_skyline) | C++14 | 191 ms | 55844 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>
#define fi first
#define se second
#define mp make_pair
#define lo long long
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 305
#define mid (start+end)/2
using namespace std;
int n,A[li],dp[li][205][205];
int dfs(int node,int h1,int h2){
int cev=inf;
if(node==n+1) return 0;
if(~dp[node][h1][h2]) return dp[node][h1][h2];
if(h1){
cev=min(cev,dfs(node,h1-1,h2)+3);
if(h2){
cev=min(cev,dfs(node,h1-1,h2-1)+5);
if(h1<=min(h2,A[node+2])){
cev=min(cev,dfs(node+1,h2-h1,A[node+2]-h1)+7*h1);
}
}
}
else cev=min(cev,dfs(node+1,h2,A[node+2]));
return dp[node][h1][h2]=cev;
}
int main(){
memset(dp,-1,sizeof(dp));
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&A[i]);
int ty=dfs(1,A[1],A[2]);
printf("%d\n",ty);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |