# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
86513 | tjdgus4384 | 요리 강좌 (KOI17_cook) | C++14 | 1059 ms | 5936 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<algorithm>
using namespace std;
int c[3001][3001], sum[3001][3001];
int x[3001], d[3001][3001];
int main()
{
int n, m, s, e, t;
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]);
sum[i][j] = sum[i][j - 1] + c[i][j];
}
}
for(int i = 1;i <= n;i++)
{
scanf("%d", &x[i]);
}
for(int j = 1;j <= m;j++)
{
for(int i = 1;i <= n;i++)
{
d[i][j] = 2e9;
for(int a = 1;a <= n;a++)
{
if(a == i || a == x[i]) continue;
for(int b = j - e;b <= j - s;b++)
{
if(b < 0) continue;
d[i][j] = min(d[i][j], d[a][b] + sum[i][j] - sum[i][b] + t);
}
}
}
}
int ans = 2e9;
for(int i = 1;i <= n;i++)
{
for(int a = 1;a <= n;a++)
{
if(a == i || a == x[i]) continue;
for(int b = m - e;b <= m;b++)
{
if(b < 0) continue;
ans = min(ans, d[a][b] + sum[i][m] - sum[i][b] + t);
}
}
}
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... |