답안 #44774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44774 2018-04-06T07:15:06 Z choikiwon 스카이라인 (IZhO11_skyline) C++17
0 / 100
38 ms 48736 KB
#include<bits/stdc++.h>
using namespace std;

int N;
int H[302];

int cc[302][202][202];
int dp(int n, int c1, int c2) {
    if(n == N) return 0;
    int &ret = cc[n][c1][c2];
    if(ret != -1) return ret;

    ret = 1e9;
    int add = c1 > c2? (c1 - c2) * 3 : 0;
    c1 = min(c1, c2);

    if(c2 <= H[n + 2]) {
        return ret = add + 7 * min(c1, c2) + dp(n + 1, c2 - c1, H[n + 2] - c1);
    }
    else return ret = add + 5 * (c2 - H[n + 2]) + 7 * (c1 - c2 + H[n + 2]) + dp(n + 1, c2 - c1, c2 - c1);
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &H[i]);
    }

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(0, H[0], H[1]));
}

Compilation message

skyline.cpp: In function 'int main()':
skyline.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
skyline.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &H[i]);
         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 48604 KB Output is correct
2 Correct 34 ms 48612 KB Output is correct
3 Correct 35 ms 48612 KB Output is correct
4 Correct 36 ms 48612 KB Output is correct
5 Correct 38 ms 48612 KB Output is correct
6 Correct 35 ms 48736 KB Output is correct
7 Correct 36 ms 48736 KB Output is correct
8 Incorrect 35 ms 48736 KB Output isn't correct
9 Halted 0 ms 0 KB -