Submission #13268

# Submission time Handle Problem Language Result Execution time Memory
13268 2015-02-07T07:20:31 Z dohyun0324 Skyline (IZhO11_skyline) C++
95 / 100
1499 ms 37432 KB
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int dap=2147483647,n,a[310],d[210][210][210],mini[210][210];
int main()
{
    int i,j,k,l;
    scanf("%d",&n);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
    {
        if(i==1) d[a[i]][0][0]=a[i]*3;
        else
        {
            for(j=0;j<=a[i];j++)
            {
                for(k=0;k<=a[i]-j;k++)
                {
                    l=a[i]-j-k;
                    if(i==1 && k) continue;
                    if(i<=2 && l) continue;
                    if(mini[k][l]!=2147483647) d[j][k][l]=3*j+2*k+2*l+mini[k][l];
                    if(d[j][k][l] && i==n && dap>d[j][k][l])
                    {
                        dap=d[j][k][l];
                    }
                }
            }
        }
        for(j=0;j<=201;j++){
            for(k=0;k<=201;k++){
                mini[j][k]=2147483647;
            }
        }
        for(j=a[i];j>=0;j--)
        {
            for(k=a[i]-j;k>=0;k--)
            {
                mini[j][k]=min(mini[j+1][k],mini[j][k+1]);
                l=a[i]-j-k;
                if(d[j][k][l] && mini[j][k]>d[j][k][l])
                {
                    mini[j][k]=d[j][k][l];
                }
            }
        }
        memset(d,0,sizeof d);
    }
    printf("%d",dap);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 37432 KB Output isn't correct
2 Correct 4 ms 37432 KB Output is correct
3 Correct 19 ms 37432 KB Output is correct
4 Correct 323 ms 37432 KB Output is correct
5 Correct 28 ms 37432 KB Output is correct
6 Correct 43 ms 37432 KB Output is correct
7 Correct 39 ms 37432 KB Output is correct
8 Correct 30 ms 37432 KB Output is correct
9 Correct 61 ms 37432 KB Output is correct
10 Correct 110 ms 37432 KB Output is correct
11 Correct 666 ms 37432 KB Output is correct
12 Correct 144 ms 37432 KB Output is correct
13 Correct 789 ms 37432 KB Output is correct
14 Correct 960 ms 37432 KB Output is correct
15 Correct 1337 ms 37432 KB Output is correct
16 Correct 1198 ms 37432 KB Output is correct
17 Correct 1486 ms 37432 KB Output is correct
18 Correct 1472 ms 37432 KB Output is correct
19 Correct 1427 ms 37432 KB Output is correct
20 Correct 1499 ms 37432 KB Output is correct