Submission #125561

#TimeUsernameProblemLanguageResultExecution timeMemory
125561eriksuenderhaufKitchen (BOI19_kitchen)C++11
100 / 100
32 ms636 KiB
#include <bits/stdc++.h> int a[301], b[301], dp[301*301], n, m, k, sm = 0; int main() { scanf("%d %d %d", &n, &m, &k), dp[0] = 1; for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sm += a[i]; for (int i = 1; i <= m; i++) scanf("%d", &b[i]); if (*std::min_element(a+1,a+n+1) < k || m < k) return !printf("Impossible\n"); for (int i = 1; i <= m; i++) for (int j = 301*301-1; j >= b[i]; j--) if (dp[j-b[i]] > 0) dp[j] = std::max(dp[j], dp[j-b[i]] + std::min(b[i],n)); for (int j = sm; j < 301*301; j++) if (dp[j] > n*k) return !printf("%d\n", j-sm); return !printf("Impossible\n"); }

Compilation message (stderr)

kitchen.cpp: In function 'int main()':
kitchen.cpp:5:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &k), dp[0] = 1;
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
kitchen.cpp:6:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sm += a[i];
                               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
kitchen.cpp:7:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= m; i++) 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...