| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 636563 | rainboy | Sightseeing in Kyoto (JOI22_kyoto) | C11 | 8 ms | 8140 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 <stdio.h>
#include <string.h>
#define N 1000
#define M 1000
#define INF 0x3f3f3f3f3f3f3f3f
long long min(long long a, long long b) { return a < b ? a : b; }
int main() {
static int aa[N], bb[M];
static long long dp[N][M];
int n, m, i, j;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
for (j = 0; j < m; j++)
scanf("%d", &bb[j]);
for (i = 0; i < n; i++)
memset(dp[i], 0x3f, m * sizeof *dp[i]);
dp[0][0] = 0;
for (i = 0; i < n; i++)
for (j = 0; j < m; j++) {
long long x = dp[i][j];
if (x == INF)
continue;
if (j + 1 < m)
dp[i][j + 1] = min(dp[i][j + 1], x + aa[i]);
if (i + 1 < n)
dp[i + 1][j] = min(dp[i + 1][j], x + bb[j]);
}
printf("%lld\n", dp[n - 1][m - 1]);
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... | ||||
