# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28680 | Sorry AcornCkiGuiziTeam (#68) | Test Data Creation (FXCUP2_testdata) | C++14 | 589 ms | 219152 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 a[90009];
int b[90009];
int d[303][303][606];
int main() {
int ti, tj;
int i, j, k, l, m, n, t;
scanf("%d%d", &m, &n);
for (i = 0; i < n * m; i++) scanf("%d", &a[i]);
for (i = 0; i < n; i++) for (j = 0; j < m; j++) for (k = 0; k <= 600; k++) d[i][j][k] = 2e9;
d[0][0][0] = 0;
for (i = 0; i < n; i++) for (j = 0; j < m; j++) for (k = 0; k <= 600; k++) {
t = i * m + j + k;
ti = t / n;
tj = t % n;
if (k) t = d[i][j][k] + a[i * m + j];
else t = d[i][j][k];
if (i + 1 < n && k >= m) d[i + 1][j][k - m] = min(d[i + 1][j][k - m], t);
if (j + 1 < m && k) d[i][j + 1][k - 1] = min(d[i][j + 1][k - 1], t);
if (k) t = d[i][j][k] + a[ti * n + tj];
else t = d[i][j][k];
if (ti + 1 < m && k + n <= 600) d[i][j][k + n] = min(d[i][j][k + n], t);
if (tj + 1 < n && k + 1 <= 600) d[i][j][k + 1] = min(d[i][j][k + 1], t);
}
printf("%d\n", d[n - 1][m - 1][0] + a[n * m - 1]);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |