# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
13341 | baneling100 | Skyline (IZhO11_skyline) | C++98 | 72 ms | 1400 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.
#include <stdio.h>
#include <algorithm>
#define N_MAX 300
#define H_MAX 200
using namespace std;
int N, H[N_MAX+3], D[2][H_MAX+1][H_MAX+1];
int main(void) {
int i, j, k, now, prev;
scanf("%d",&N);
for(i=1 ; i<=N ; i++)
scanf("%d",&H[i]);
for(i=0 ; i<=H[1] ; i++)
for(j=0 ; j<=H[2] ; j++)
D[0][i][j]=5*min(i,j)+3*(max(i,j)-min(i,j));
for(i=1 ; i<=N ; i++) {
now=i%2;
prev=(i-1)%2;
for(j=0 ; j<=H[i+1] ; j++) {
D[now][j][0]=D[prev][H[i]][j];
for(k=1 ; k<=H[i+2] ; k++) {
D[now][j][k]=D[now][j][k-1]+3;
if(j) D[now][j][k]=min(D[now][j][k],D[now][j-1][k-1]+5);
if(H[i]>=k && j>=k) D[now][j][k]=min(D[now][j][k],D[prev][H[i]-k][j-k]+7*k);
}
}
}
printf("%d",D[N%2][0][0]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |