Submission #97062

#TimeUsernameProblemLanguageResultExecution timeMemory
97062KalamSkyline (IZhO11_skyline)C++11
100 / 100
287 ms210232 KiB
// KALAM # include<bits/stdc++.h> using namespace std; const int N = 300 + 77 , inf = 1000000077; int n , a[N] , dp[N][N][N]; int main(){ memset(dp , 63 , sizeof(dp)); cin >> n; for(int i = 1;i <= n;++ i) cin >> a[i]; for(int i = 0;i <= a[1];++ i) dp[1][0][i] = 3 * i; for(int id = 2;id <= n;++ id) for(int j = 0;j <= a[id];++ j) for(int i = 0;i <= a[id - 1];++ i){ int now = id , prv = id - 1; if(j > 0) dp[now][i][j] = dp[now][i][j - 1] + 3; if(min(i , j) > 0) dp[now][i][j] = min(dp[now][i][j] , dp[now][i - 1][j - 1] + 5); int t = min(i , j); if(t <= a[id - 2]) dp[now][i][j] = min(dp[now][i][j] , dp[prv][a[id - 2] - t][i - t] + t * 7 + (j - t) * 3); } cout << dp[n][a[n - 1]][a[n]]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...