# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132209 | sean617 | 요리 강좌 (KOI17_cook) | C++98 | 1058 ms | 60432 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 <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define N 3005
#define F first
#define S second
#define PI pair<int, int>
using namespace std;
int n, m, S, E, T, st, a[N][N], d[N][N], s[N][N], b[N];
vector<PI> mx[N];
int main()
{
int i, j, k, x;
cin >> n >> m >> S >> E >> T;
for (i = 1; i <= n; i++) {
for (j = 1; j <= m; j++) {
scanf ("%d", &a[i][j]);
s[i][j] = s[i][j - 1] + a[i][j];
}
}
for (i = 1; i <= n; i++) {
scanf ("%d", &b[i]);
}
for (j = 1; j <= m; j++) {
for (i = 1; i <= n; i++) {
d[i][j] = 2e9;
if (j == m) st =1;
else st = S;
for (k = st; k <= E && j - k >= 0; k++) {
x = s[i][j] - s[i][j - k];
if (j - k > 0) {
if (mx[j - k][0].S == b[i] || mx[j - k][0].S == i) x += mx[j - k][1].F;
else x += mx[j - k][0].F;
x += T;
}
d[i][j] = min(d[i][j], x);
}
mx[j].push_back(PI(d[i][j], i));
}
sort(mx[j].begin(), mx[j].end());
}
cout << mx[m][0].F;
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... |