Submission #522782

#TimeUsernameProblemLanguageResultExecution timeMemory
522782LucaDantasKitchen (BOI19_kitchen)C++17
0 / 100
25 ms656 KiB
#include <cstdio> constexpr int maxn = 310, inf = 0x3f3f3f3f; int a[maxn], b[maxn]; int dp[maxn*maxn]; int main() { int n, m, k; scanf("%d %d %d", &n, &m, &k); for(int i = 0; i < n; i++) scanf("%d", a+i); for(int i = 0; i < m; i++) scanf("%d", b+i); int soma = 0; for(int i = 0; i < n; i++) { soma += a[i]; if(a[i] < k) return puts("impossible"), 0; } auto max = [](int a, int b) { return a > b ? a : b; }; auto min = [](int a, int b) { return a < b ? a : b; }; for(int i = 0; i < maxn*maxn; i++) dp[i] = -inf; dp[0] = 0; for(int i = 0; i < m; i++) for(int j = maxn*maxn - 1 - b[i]; j >= 0; j--) dp[j+b[i]] = max(dp[j+b[i]], dp[j] + min(n, b[i])); for(int j = soma; j < maxn*maxn; j++) if(dp[j] >= n*k) return printf("%d\n", j-soma), 0; puts("impossible"); }

Compilation message (stderr)

kitchen.cpp: In function 'int main()':
kitchen.cpp:10:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  int n, m, k; scanf("%d %d %d", &n, &m, &k);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d", a+i);
      |   ~~~~~^~~~~~~~~~~
kitchen.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", b+i);
      |   ~~~~~^~~~~~~~~~~
#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...