Submission #1224146

#TimeUsernameProblemLanguageResultExecution timeMemory
1224146sleepntsheepKitchen (BOI19_kitchen)C++17
100 / 100
28 ms1040 KiB
#include <stdio.h> #include <string.h> #include <bitset> #include <algorithm> #define N 405 int n, m, k, a[N], b[N], sum, ans = 1e9; int dp[N * N]; int main() { scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]), sum += a[i]; if (a[i] < k) { puts("Impossible"); return 0; } } memset(dp, 0xbf, sizeof dp); dp[0] = 0; for (int i = 1; i <= m; ++i) { scanf("%d", &b[i]); int x_ = b[i] < n ? b[i] : n, y_ = b[i]; for (int j = N * N - 1; j >= y_; --j) { dp[j] = std::max(dp[j], dp[j - y_] + x_); } } for (int h = 0; h + sum < N * N; ++h) { if (dp[sum + h] >= k * n) { printf("%d\n", h); return 0; } } puts("Impossible"); return 0; }

Compilation message (stderr)

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