Submission #338171

#TimeUsernameProblemLanguageResultExecution timeMemory
338171juggernautSkyline (IZhO11_skyline)C++14
100 / 100
194 ms49604 KiB
#include <bits/stdc++.h> #define INF 1000000000 using namespace std; const int N=303; const int M=202; int dp[N][M][M],arr[N],n; int rec(int pos,int a1,int a2){ if(pos>=n) return min(a1,a2)*5+(max(a1,a2)-min(a1,a2))*3; int &ret=dp[pos][a1][a2]; if(~ret) return ret; ret=INF; int val=min(arr[pos],min(a1,a2)); if(val==a2) ret=min(ret,rec(pos+1,arr[pos]-val,a1-val)+val*7); if(a1 and a2) ret=min(ret,rec(pos,a1-1,a2-1)+5); if(a2) ret=min(ret,rec(pos,a1,a2-1)+3); return ret; //a2 a1 a[pos] } int main(){ scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",arr+i); memset(dp,-1,sizeof dp); printf("%d\n",rec(2,arr[1],arr[0])); return 0; }

Compilation message (stderr)

skyline.cpp: In function 'int main()':
skyline.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
skyline.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |   scanf("%d",arr+i);
      |   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...