# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
86248 | tjdgus4384 | 요리 강좌 (KOI17_cook) | C++14 | 46 ms | 36120 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |