Submission #544746

#TimeUsernameProblemLanguageResultExecution timeMemory
544746rainboyKitchen (BOI19_kitchen)C11
100 / 100
28 ms640 KiB
#include <stdio.h> #include <string.h> #define N 300 #define M 300 #define K 300 #define B 300 #define S (M * B) 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[S + 1]; int n, m, k, i, s, s_; scanf("%d%d%d", &n, &m, &k); if (m < k) { printf("Impossible\n"); return 0; } s_ = 0; for (i = 0; i < n; i++) { int a; scanf("%d", &a); if (a < k) { printf("Impossible\n"); return 0; } s_ += a; } memset(dp, -1, sizeof dp), dp[0] = 0; while (m--) { int b; scanf("%d", &b); for (s = S; s >= b; s--) if (dp[s - b] != -1) dp[s] = max(dp[s], dp[s - b] + min(b, n)); } for (s = s_; s <= S; s++) if (dp[s] >= n * k) { printf("%d\n", s - s_); return 0; } printf("Impossible\n"); return 0; }

Compilation message (stderr)

kitchen.c: In function 'main':
kitchen.c:17:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d%d%d", &n, &m, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
kitchen.c:26:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d", &a);
      |   ^~~~~~~~~~~~~~~
kitchen.c:37:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   scanf("%d", &b);
      |   ^~~~~~~~~~~~~~~
#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...