Submission #85884

#TimeUsernameProblemLanguageResultExecution timeMemory
85884farukkastamonudaSkyline (IZhO11_skyline)C++14
100 / 100
191 ms55844 KiB
#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)

skyline.cpp: In function 'int main()':
skyline.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
skyline.cpp:32:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&A[i]);
                        ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...