Submission #536331

#TimeUsernameProblemLanguageResultExecution timeMemory
536331rainboy도장 모으기 (JOI14_stamps)C11
100 / 100
163 ms460 KiB
#include <stdio.h> #include <string.h> #define N 3000 #define M ((N + 2) * 2) #define INF 0x3f3f3f3f3f3f3f3fLL long long min(long long a, long long b) { return a < b ? a : b; } int main() { static long long dp[M + 1], dq[M + 1]; int n, m, t, k; scanf("%d%d", &n, &t), m = (n + 2) * 2; memset(dp, 0x3f, (m + 1) * sizeof *dp), dp[0] = t; while (n--) { int u, v, d, e; scanf("%d%d%d%d", &u, &v, &d, &e); memset(dq, 0x3f, (m + 1) * sizeof *dq); for (k = 0; k <= m; k++) { long long x = dp[k]; if (x == INF) continue; dq[k] = min(dq[k], x + u + v); if (k > 0) { dq[k] = min(dq[k], x + d + e); dq[k - 1] = min(dq[k - 1], x + u + e); } if (k < m) dq[k + 1] = min(dq[k + 1], x + d + v); } for (k = m; k > 0; k--) dq[k - 1] = min(dq[k - 1], dq[k] + u + e); for (k = 0; k < m; k++) dq[k + 1] = min(dq[k + 1], dq[k] + d + v); memcpy(dp, dq, (m + 1) * sizeof *dq); for (k = 0; k <= m; k++) if (dp[k] != INF) dp[k] += (long long) t * (k * 2 + 1); } printf("%lld\n", dp[0]); return 0; }

Compilation message (stderr)

stamps.c: In function 'main':
stamps.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d%d", &n, &t), m = (n + 2) * 2;
      |  ^~~~~~~~~~~~~~~~~~~~~
stamps.c:19:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d%d%d%d", &u, &v, &d, &e);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...