답안 #97062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97062 2019-02-13T16:03:05 Z Kalam 스카이라인 (IZhO11_skyline) C++11
100 / 100
287 ms 210232 KB
// 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 173 ms 210168 KB Output is correct
2 Correct 193 ms 210040 KB Output is correct
3 Correct 163 ms 210040 KB Output is correct
4 Correct 162 ms 210040 KB Output is correct
5 Correct 181 ms 209996 KB Output is correct
6 Correct 163 ms 210012 KB Output is correct
7 Correct 167 ms 210040 KB Output is correct
8 Correct 177 ms 210192 KB Output is correct
9 Correct 182 ms 209972 KB Output is correct
10 Correct 183 ms 210040 KB Output is correct
11 Correct 203 ms 210188 KB Output is correct
12 Correct 182 ms 210052 KB Output is correct
13 Correct 197 ms 210232 KB Output is correct
14 Correct 211 ms 210168 KB Output is correct
15 Correct 261 ms 210040 KB Output is correct
16 Correct 249 ms 210040 KB Output is correct
17 Correct 254 ms 210040 KB Output is correct
18 Correct 261 ms 210120 KB Output is correct
19 Correct 256 ms 210084 KB Output is correct
20 Correct 287 ms 210140 KB Output is correct