Submission #636563

#TimeUsernameProblemLanguageResultExecution timeMemory
636563rainboySightseeing in Kyoto (JOI22_kyoto)C11
10 / 100
8 ms8140 KiB
#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)

kyoto.c: In function 'main':
kyoto.c:15:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
kyoto.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
kyoto.c:19:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d", &bb[j]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...