Submission #537113

#TimeUsernameProblemLanguageResultExecution timeMemory
537113rainboy스트랩 (JOI14_straps)C11
100 / 100
21 ms436 KiB
#include <stdio.h> #include <string.h> #define N 2000 #define INF 0x7fffffff int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } int main() { static int dp[N + N + 1], dq[N + N + 1]; int n, i, s, t, ans; scanf("%d", &n); for (s = -n; s <= n; s++) dp[n + s] = -INF; dp[n + 1] = 0; for (i = 0; i < n; i++) { int a, b; scanf("%d%d", &a, &b), a--; memcpy(dq, dp, (n * 2 + 1) * sizeof *dp); for (s = -n; s <= n; s++) { int x = dq[n + s]; if (x == -INF) continue; t = min(s + a, n); dp[n + t] = max(dp[n + t], x + b); } } ans = -INF; for (s = 0; s <= n; s++) ans = max(ans, dp[n + s]); printf("%d\n", ans); return 0; }

Compilation message (stderr)

straps.c: In function 'main':
straps.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
straps.c:21:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d%d", &a, &b), a--;
      |   ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...