답안 #56924

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56924 2018-07-13T08:03:29 Z red1108 리조트 (KOI16_resort) C++17
100 / 100
4 ms 1160 KB
#include <stdio.h>
#include <utility>
#include <algorithm>
using namespace std;
int dp[110][50],mindp[110];
bool go[110];
int n, m,ans;
void f(int day,int c,int money)
{
    if(day>n)
    {
        if(ans==0||ans>money) ans=money;
        return ;
    }
    if(dp[day][c]!=0&&dp[day][c]<=money) return ;
    if(dp[day][mindp[day]]!=0&&(dp[day][mindp[day]]<=money&&mindp[day]>c)) return ;
    if(dp[day][c]==0||dp[day][c]>money){
            dp[day][c]=money;
            if(dp[day][mindp[day]]==0||dp[day][mindp[day]]>money||(dp[day][mindp[day]]==money&&mindp[day]<c)) mindp[day]=c;
    }
    if(go[day]==0) f(day+1,c,money);
    else {
    f(day+5,c+2,money+37000);
    f(day+3,c+1,money+25000);
    f(day+1,c,money+10000);
    if(c>=3){f(day+1,c-3,money);}
    }
}
int main()
{
    int i;
    scanf("%d %d",&n,&m);
    fill(go,go+n+1,1);
    fill(mindp,mindp+n+1,0);
    for(i=1;i<=m;i++)
    {
        int a;
        scanf("%d", &a);
        go[a]=0;
    }
    f(1,0,0);
    printf("%d", ans);
}

Compilation message

resort.cpp: In function 'int main()':
resort.cpp:32: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:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 700 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
9 Correct 2 ms 748 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 2 ms 748 KB Output is correct
3 Correct 2 ms 748 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 2 ms 748 KB Output is correct
6 Correct 3 ms 748 KB Output is correct
7 Correct 2 ms 748 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
9 Correct 3 ms 748 KB Output is correct
10 Correct 2 ms 784 KB Output is correct
11 Correct 3 ms 784 KB Output is correct
12 Correct 3 ms 820 KB Output is correct
13 Correct 2 ms 820 KB Output is correct
14 Correct 2 ms 820 KB Output is correct
15 Correct 2 ms 820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 700 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
9 Correct 2 ms 748 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 2 ms 748 KB Output is correct
12 Correct 2 ms 748 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Correct 2 ms 748 KB Output is correct
15 Correct 2 ms 748 KB Output is correct
16 Correct 3 ms 748 KB Output is correct
17 Correct 2 ms 748 KB Output is correct
18 Correct 2 ms 748 KB Output is correct
19 Correct 3 ms 748 KB Output is correct
20 Correct 2 ms 784 KB Output is correct
21 Correct 3 ms 784 KB Output is correct
22 Correct 3 ms 820 KB Output is correct
23 Correct 2 ms 820 KB Output is correct
24 Correct 2 ms 820 KB Output is correct
25 Correct 2 ms 820 KB Output is correct
26 Correct 2 ms 848 KB Output is correct
27 Correct 3 ms 980 KB Output is correct
28 Correct 2 ms 980 KB Output is correct
29 Correct 2 ms 984 KB Output is correct
30 Correct 3 ms 988 KB Output is correct
31 Correct 2 ms 992 KB Output is correct
32 Correct 2 ms 996 KB Output is correct
33 Correct 3 ms 1000 KB Output is correct
34 Correct 2 ms 1004 KB Output is correct
35 Correct 2 ms 1008 KB Output is correct
36 Correct 2 ms 1012 KB Output is correct
37 Correct 3 ms 1016 KB Output is correct
38 Correct 4 ms 1020 KB Output is correct
39 Correct 2 ms 1024 KB Output is correct
40 Correct 3 ms 1028 KB Output is correct
41 Correct 2 ms 1152 KB Output is correct
42 Correct 2 ms 1160 KB Output is correct
43 Correct 2 ms 1160 KB Output is correct
44 Correct 3 ms 1160 KB Output is correct