# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140826 | 2019-08-05T12:25:40 Z | Shelby | Kitchen (BOI19_kitchen) | C++11 | 42 ms | 848 KB |
#include <bits/stdc++.h> #define MAXN 305 using namespace std; int dp[MAXN*MAXN],a[MAXN],b[MAXN],val[MAXN]; bool ok[MAXN*MAXN]; int main() { int i,j,n,m,k,sum=0,need=0,mn; scanf("%d%d%d",&n,&m,&k); for(i=0;i<n;i++) { scanf("%d",&a[i]); if(i==0) mn=a[i]; else mn=min(mn,a[i]); sum=sum+a[i]; need+=k; } for(i=0;i<m;i++) { scanf("%d",&b[i]); val[i]=min(b[i],n); } ok[0]=true; for(i=0;i<m;i++) { for(j=MAXN*MAXN-1;j>=b[i];j--) { if(ok[j-b[i]]==true) { ok[j]=true; dp[j]=max(dp[j], dp[j-b[i]]+val[i] ); } } } if(mn<k) printf("Impossible\n"); else { for(i=sum;i<MAXN*MAXN;i++) { if(ok[i]==true && dp[i]>=need) { printf("%d\n",i-sum); return 0; } } printf("Impossible\n"); } //for(i=0;i<9;i++) cout << dp[i] << " "; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 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 | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 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 | 376 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 636 KB | Output is correct |
2 | Correct | 24 ms | 632 KB | Output is correct |
3 | Correct | 32 ms | 504 KB | Output is correct |
4 | Correct | 38 ms | 760 KB | Output is correct |
5 | Correct | 35 ms | 760 KB | Output is correct |
6 | Correct | 23 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 6 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 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 | 376 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 29 ms | 636 KB | Output is correct |
15 | Correct | 24 ms | 632 KB | Output is correct |
16 | Correct | 32 ms | 504 KB | Output is correct |
17 | Correct | 38 ms | 760 KB | Output is correct |
18 | Correct | 35 ms | 760 KB | Output is correct |
19 | Correct | 23 ms | 504 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 5 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 6 ms | 376 KB | Output is correct |
25 | Correct | 23 ms | 848 KB | Output is correct |
26 | Correct | 28 ms | 632 KB | Output is correct |
27 | Correct | 17 ms | 504 KB | Output is correct |
28 | Correct | 27 ms | 580 KB | Output is correct |
29 | Correct | 31 ms | 632 KB | Output is correct |
30 | Correct | 42 ms | 760 KB | Output is correct |