답안 #58587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58587 2018-07-18T10:42:11 Z andy627 리조트 (KOI16_resort) C++17
100 / 100
4 ms 836 KB
#include <stdio.h>
#include <algorithm>
#define INF 999999999
using namespace std;

int dp[111][44];
bool cant[111];

int main(){
    int n,m;

    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        int num;
        scanf("%d",&num);
        cant[num]=1;
    }


    for(int i=0;i<=n;i++){
        for(int j=0;j<=40;j++) dp[i][j]=INF;
    }
    dp[0][0]=0;

    for(int i=0;i<=n;i++){
        for(int j=0;j<=40;j++){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]+10);
            dp[i+3][j+1]=min(dp[i+3][j+1],dp[i][j]+25);
            dp[i+5][j+2]=min(dp[i+5][j+2],dp[i][j]+37);
            if(j>=3) dp[i+1][j-3]=min(dp[i+1][j-3],dp[i][j]);

            if(cant[i+1]) dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
        }
    }

    int mn=INF;
    for(int i=0;i<=40;i++) mn=min(mn,dp[n][i]);

    printf("%d",mn*1000);

    return 0;
}

Compilation message

resort.cpp: In function 'int main()':
resort.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
resort.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&num);
         ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 3 ms 368 KB Output is correct
3 Correct 2 ms 368 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 3 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 652 KB Output is correct
2 Correct 2 ms 652 KB Output is correct
3 Correct 2 ms 660 KB Output is correct
4 Correct 2 ms 664 KB Output is correct
5 Correct 3 ms 664 KB Output is correct
6 Correct 3 ms 664 KB Output is correct
7 Correct 3 ms 664 KB Output is correct
8 Correct 3 ms 676 KB Output is correct
9 Correct 2 ms 692 KB Output is correct
10 Correct 2 ms 800 KB Output is correct
11 Correct 2 ms 800 KB Output is correct
12 Correct 2 ms 800 KB Output is correct
13 Correct 4 ms 800 KB Output is correct
14 Correct 3 ms 800 KB Output is correct
15 Correct 3 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 3 ms 368 KB Output is correct
3 Correct 2 ms 368 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 3 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 3 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 660 KB Output is correct
14 Correct 2 ms 664 KB Output is correct
15 Correct 3 ms 664 KB Output is correct
16 Correct 3 ms 664 KB Output is correct
17 Correct 3 ms 664 KB Output is correct
18 Correct 3 ms 676 KB Output is correct
19 Correct 2 ms 692 KB Output is correct
20 Correct 2 ms 800 KB Output is correct
21 Correct 2 ms 800 KB Output is correct
22 Correct 2 ms 800 KB Output is correct
23 Correct 4 ms 800 KB Output is correct
24 Correct 3 ms 800 KB Output is correct
25 Correct 3 ms 800 KB Output is correct
26 Correct 2 ms 836 KB Output is correct
27 Correct 2 ms 836 KB Output is correct
28 Correct 2 ms 836 KB Output is correct
29 Correct 2 ms 836 KB Output is correct
30 Correct 2 ms 836 KB Output is correct
31 Correct 2 ms 836 KB Output is correct
32 Correct 2 ms 836 KB Output is correct
33 Correct 2 ms 836 KB Output is correct
34 Correct 3 ms 836 KB Output is correct
35 Correct 2 ms 836 KB Output is correct
36 Correct 2 ms 836 KB Output is correct
37 Correct 3 ms 836 KB Output is correct
38 Correct 3 ms 836 KB Output is correct
39 Correct 3 ms 836 KB Output is correct
40 Correct 3 ms 836 KB Output is correct
41 Correct 3 ms 836 KB Output is correct
42 Correct 3 ms 836 KB Output is correct
43 Correct 4 ms 836 KB Output is correct
44 Correct 2 ms 836 KB Output is correct