답안 #682750

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
682750 2023-01-17T00:18:58 Z Summers 스카이라인 (IZhO11_skyline) C++14
100 / 100
127 ms 95400 KB
#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

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;
      |                           ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 2 ms 2132 KB Output is correct
4 Correct 10 ms 22740 KB Output is correct
5 Correct 2 ms 2536 KB Output is correct
6 Correct 2 ms 3796 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 4684 KB Output is correct
10 Correct 5 ms 8148 KB Output is correct
11 Correct 26 ms 45148 KB Output is correct
12 Correct 7 ms 10068 KB Output is correct
13 Correct 35 ms 53140 KB Output is correct
14 Correct 41 ms 63560 KB Output is correct
15 Correct 94 ms 87252 KB Output is correct
16 Correct 86 ms 78436 KB Output is correct
17 Correct 127 ms 95400 KB Output is correct
18 Correct 125 ms 94936 KB Output is correct
19 Correct 109 ms 91344 KB Output is correct
20 Correct 121 ms 95392 KB Output is correct