Submission #299865

#TimeUsernameProblemLanguageResultExecution timeMemory
299865ly20Kitchen (BOI19_kitchen)C++17
0 / 100
4 ms512 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 310; bool dp[MAXN * MAXN]; int sm[MAXN]; int n, m, k; int main() { bool ok = true; scanf("%d %d %d", &n, &m, &k); int ms = 0; for(int i = 0; i < n; i++) { int a; scanf("%d", &a); ms += a; if(a < k) ok = false; } //printf("%d\n", ms); if(m < k) ok = false; dp[0] = 1; for(int i = 0; i < m; i++) { int a; scanf("%d", &a); for(int j = MAXN * MAXN - 1; j >= a; j--) { int p = min(n, a); if(dp[j - a]) { //printf("%d\n", j); dp[j] = 1; int t = p + sm[j - a]; sm[j] = max(t, sm[j]); //printf("%d\n", sm[j]); } } } int ft = ms - 1; for(int i = ms; i < MAXN * MAXN; i++) { if(sm[i] >= n * k) { //printf("%d\n", i); ft = i; break; } } if(ft == ms - 1 || !ok) printf("Impossible\n"); else printf("%d\n", ft - ms); return 0; }

Compilation message (stderr)

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