Submission #566746

# Submission time Handle Problem Language Result Execution time Memory
566746 2022-05-22T19:30:25 Z milisav Kitchen (BOI19_kitchen) C++14
100 / 100
28 ms 676 KB
#include<bits/stdc++.h>
#define maxn 305
using namespace std;
int n,m,k;
int a[maxn];
int b[maxn];
int dp[maxn*maxn];
int main() {
    scanf("%d %d %d",&n,&m,&k);
    int sm=0;
    int mn=1e9;
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        sm+=a[i];
        mn=min(mn,a[i]);
    }
    for(int i=1;i<=m;i++) scanf("%d",&b[i]);
    if(mn<k) {
        printf("Impossible");
        return 0;
    }
    for(int i=1;i<maxn*maxn;i++) dp[i]=-1e9;
    for(int i=1;i<=m;i++) {
        int val=min(n,b[i]);
        for(int j=maxn*maxn-1;j>=b[i];j--) {
            dp[j]=max(dp[j],dp[j-b[i]]+val);
        }
    }
    int ans=-1;
    for(int i=sm;i<maxn*maxn;i++) {
        if(dp[i]>=n*k) {
            ans=i;
            break;
        }
    }
    if(ans==-1) printf("Impossible");
    else printf("%d",ans-sm);
    return 0;
}

Compilation message

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[i]);
      |         ~~~~~^~~~~~~~~~~~
kitchen.cpp:17:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     for(int i=1;i<=m;i++) scanf("%d",&b[i]);
      |                           ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 568 KB Output is correct
4 Correct 1 ms 572 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 568 KB Output is correct
4 Correct 1 ms 572 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 572 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 576 KB Output is correct
2 Correct 19 ms 672 KB Output is correct
3 Correct 28 ms 596 KB Output is correct
4 Correct 25 ms 676 KB Output is correct
5 Correct 24 ms 596 KB Output is correct
6 Correct 26 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 596 KB Output is correct
2 Correct 4 ms 596 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 0 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 568 KB Output is correct
4 Correct 1 ms 572 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 572 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 23 ms 576 KB Output is correct
15 Correct 19 ms 672 KB Output is correct
16 Correct 28 ms 596 KB Output is correct
17 Correct 25 ms 676 KB Output is correct
18 Correct 24 ms 596 KB Output is correct
19 Correct 26 ms 596 KB Output is correct
20 Correct 5 ms 596 KB Output is correct
21 Correct 4 ms 596 KB Output is correct
22 Correct 4 ms 596 KB Output is correct
23 Correct 3 ms 596 KB Output is correct
24 Correct 0 ms 320 KB Output is correct
25 Correct 17 ms 596 KB Output is correct
26 Correct 21 ms 596 KB Output is correct
27 Correct 18 ms 568 KB Output is correct
28 Correct 27 ms 572 KB Output is correct
29 Correct 21 ms 596 KB Output is correct
30 Correct 26 ms 596 KB Output is correct