# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
86565 | tjdgus4384 | 리조트 (KOI16_resort) | C++14 | 3 ms | 892 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |