# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
86248 | tjdgus4384 | 요리 강좌 (KOI17_cook) | C++14 | 46 ms | 36120 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<algorithm>
using namespace std;
int c[3001][3001];
int cant[3001], csum[3001][3001];
int d[3001][3001], ans = 1000000000, n, m, s, e, t;
int recur(int x, int y)
{
if(y == 0) return 0;
if(y < s) return 1000000000;
if(d[x][y] != -1) return d[x][y];
d[x][y] = 1000000000;
for(int i = s;i <= e;i++)
{
if(y < i) break;
int ret = csum[x][y] - csum[x][y - i];
int a = 1000000000;
for(int j = 1;j <= n;j++)
{
if(j == x || j == cant[x]) continue;
a = min(a, recur(j, y - i));
}
d[x][y] = min(d[x][y], ret + a);
}
d[x][y] += t;
return d[x][y];
}
int main()
{
scanf("%d %d %d %d %d", &n, &m, &s, &e, &t);
for(int i = 1;i <= n;i++)
{
for(int j = 1;j <= m;j++)
{
scanf("%d", &c[i][j]);
csum[i][j] = csum[i][j - 1] + c[i][j];
}
}
for(int i = 1;i <= n;i++) scanf("%d", &cant[i]);
memset(d, -1, sizeof(d));
for(int i = 1;i <= n;i++)
{
ans = min(ans, recur(i, m));
}
printf("%d", ans - t);
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |