Submission #86565

#TimeUsernameProblemLanguageResultExecution timeMemory
86565tjdgus4384리조트 (KOI16_resort)C++14
100 / 100
3 ms892 KiB
#include<cstdio>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;
int cant[101];
int d[101][101], n;

int dfs(int x, int c)
{
    if(x >= n + 1) return 0;
    if(d[x][c] != -1) return d[x][c];
    d[x][c] = 2e9;
    if(cant[x]) d[x][c] = dfs(x + 1, c);
    else if(c >= 3) d[x][c] = dfs(x + 1, c - 3);
    else d[x][c] = dfs(x + 1, c) + 10000;

    d[x][c] = min(d[x][c], dfs(x + 3, c + 1) + 25000);
    d[x][c] = min(d[x][c], dfs(x + 5, c + 2) + 37000);
    return d[x][c];
}

int main()
{
    int m, x;
    scanf("%d %d", &n, &m);
    for(int i = 0;i < m;i++)
    {
        scanf("%d", &x);
        cant[x] = 1;
    }
    memset(d, -1, sizeof(d));
    printf("%d", dfs(1, 0));
    return 0;
}

Compilation message (stderr)

resort.cpp: In function 'int main()':
resort.cpp:26: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:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...