Submission #590130

#TimeUsernameProblemLanguageResultExecution timeMemory
590130rainboyUplifting Excursion (BOI22_vault)C11
5 / 100
2860 ms2256 KiB
#include <stdio.h> #include <string.h> #define N 50 #define S 125000 int max(int a, int b) { return a > b ? a : b; } int main() { static int aa[N * 2 + 1], dp[S * 2 + 1]; int n, i, s; long long s_; scanf("%d%lld", &n, &s_); for (i = -n; i <= n; i++) scanf("%d", &aa[i + n]); if (s_ < -S || s_ > S) { printf("impossible\n"); return 0; } memset(dp, -1, (S * 2 + 1) * sizeof *dp), dp[S + 0] = 0; for (i = -n; i <= n; i++) while (aa[i + n]--) { if (i < 0) { for (s = -S; s <= S; s++) if (dp[S + s] != -1) dp[S + s + i] = max(dp[S + s + i], dp[S + s] + 1); } else { for (s = S; s >= -S; s--) if (dp[S + s] != -1) dp[S + s + i] = max(dp[S + s + i], dp[S + s] + 1); } } if (dp[S + s_] == -1) printf("impossible\n"); else printf("%d\n", dp[S + s_]); return 0; }

Compilation message (stderr)

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