Submission #682750

#TimeUsernameProblemLanguageResultExecution timeMemory
682750SummersSkyline (IZhO11_skyline)C++14
100 / 100
127 ms95400 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; long long a[1000000], dp[301][201][201]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long i,j,p,n,m,t,mini; cin>>n; for(i=1;i<=n;i++) { cin>>a[i]; } for(i=0;i<=n;i++) { for(j=0;j<=200;j++) { for(p=0;p<=200;p++)dp[i][p][j]=10000000000; } } for(i=0;i<=a[1];i++) dp[1][0][i]=3*i; for(i=2;i<=n;i++) { for(j=0;j<=a[i-1];j++) { for(p=0;p<=a[i];p++) { if(p>0)dp[i][j][p]=dp[i][j][p-1]+3; if(p>0 && j>0)dp[i][j][p]=min(dp[i][j][p], dp[i][j-1][p-1]+5); int mini=min(j,p); if(mini<=a[i-2]) { dp[i][j][p]=min(dp[i][j][p], dp[i-1][a[i-2]-mini][j-mini]+7*mini+3*(p-mini)); } } } } cout<<dp[n][a[n-1]][a[n]]<<endl; }

Compilation message (stderr)

skyline.cpp: In function 'int main()':
skyline.cpp:11:23: warning: unused variable 'm' [-Wunused-variable]
   11 |     long long i,j,p,n,m,t,mini;
      |                       ^
skyline.cpp:11:25: warning: unused variable 't' [-Wunused-variable]
   11 |     long long i,j,p,n,m,t,mini;
      |                         ^
skyline.cpp:11:27: warning: unused variable 'mini' [-Wunused-variable]
   11 |     long long i,j,p,n,m,t,mini;
      |                           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...