Submission #139925

# Submission time Handle Problem Language Result Execution time Memory
139925 2019-08-01T16:38:02 Z ae04071 Kitchen (BOI19_kitchen) C++11
100 / 100
29 ms 760 KB
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e8;

int n,m,K,a[300],b[300];
int dp[90001];

int main() {
    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 as=0;
    for(int i=0;i<n;i++) {
        if(a[i]<K) {
            puts("Impossible");
            return 0;
        }as+=a[i];
    }

    for(int i=1;i<=90000;i++) dp[i] = -INF;
    for(int i=0;i<m;i++) {
        for(int j=90000-b[i];j>=0;j--) dp[j+b[i]] = max(dp[j+b[i]], dp[j] + min(n,b[i]));
    }
    
    for(int i=as;i<=90000;i++) if(dp[i] >= n*K) {
        printf("%d\n",i - as);
        return 0;
    }
    puts("Impossible");
    
    return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&m,&K);
     ~~~~~^~~~~~~~~~~~~~~~~~~
kitchen.cpp:11:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++) scanf("%d",a+i);
                          ~~~~~^~~~~~~~~~
kitchen.cpp:12:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<m;i++) scanf("%d",b+i);
                          ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 4 ms 632 KB Output is correct
10 Correct 4 ms 760 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
12 Correct 4 ms 632 KB Output is correct
13 Correct 4 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 752 KB Output is correct
2 Correct 22 ms 632 KB Output is correct
3 Correct 29 ms 632 KB Output is correct
4 Correct 28 ms 760 KB Output is correct
5 Correct 27 ms 716 KB Output is correct
6 Correct 20 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 632 KB Output is correct
2 Correct 6 ms 632 KB Output is correct
3 Correct 6 ms 632 KB Output is correct
4 Correct 6 ms 760 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 4 ms 632 KB Output is correct
10 Correct 4 ms 760 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
12 Correct 4 ms 632 KB Output is correct
13 Correct 4 ms 680 KB Output is correct
14 Correct 25 ms 752 KB Output is correct
15 Correct 22 ms 632 KB Output is correct
16 Correct 29 ms 632 KB Output is correct
17 Correct 28 ms 760 KB Output is correct
18 Correct 27 ms 716 KB Output is correct
19 Correct 20 ms 760 KB Output is correct
20 Correct 6 ms 632 KB Output is correct
21 Correct 6 ms 632 KB Output is correct
22 Correct 6 ms 632 KB Output is correct
23 Correct 6 ms 760 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 20 ms 636 KB Output is correct
26 Correct 23 ms 632 KB Output is correct
27 Correct 16 ms 632 KB Output is correct
28 Correct 23 ms 636 KB Output is correct
29 Correct 24 ms 732 KB Output is correct
30 Correct 28 ms 632 KB Output is correct