# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97062 | Kalam | Skyline (IZhO11_skyline) | C++11 | 287 ms | 210232 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.
// 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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |