# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
719580 | 2023-04-06T10:05:04 Z | jamezzz | Kitchen (BOI19_kitchen) | C++17 | 291 ms | 111436 KB |
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define INF 1023456789 #define maxn 305 int n,m,k,a[maxn],b[maxn],memo[maxn][maxn*maxn+5]; int dp(int i,int num){ if(num<0)return -INF; if(i==-1&&num==0)return 0; if(i==-1&&num!=0)return -INF; if(memo[i][num]!=-1)return memo[i][num]; return memo[i][num]=max(dp(i-1,num),dp(i-1,num-b[i])+min(n,b[i])); } int main(){ sf("%d%d%d",&n,&m,&k); int sm=0; for(int i=0;i<n;++i){ sf("%d",&a[i]); if(a[i]<k){ printf("Impossible\n"); exit(0); } sm+=a[i]; } int sm2=0; for(int i=0;i<m;++i){ sf("%d",&b[i]); sm2+=b[i]; } memset(memo,-1,sizeof memo); for(int i=sm;i<=sm2;++i){ if(dp(m-1,i)>=n*k){ printf("%d\n",i-sm); exit(0); } } printf("Impossible\n"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 111308 KB | Output is correct |
2 | Correct | 40 ms | 111344 KB | Output is correct |
3 | Correct | 47 ms | 111268 KB | Output is correct |
4 | Correct | 40 ms | 111316 KB | Output is correct |
5 | Correct | 43 ms | 111304 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 41 ms | 111312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 111308 KB | Output is correct |
2 | Correct | 40 ms | 111344 KB | Output is correct |
3 | Correct | 47 ms | 111268 KB | Output is correct |
4 | Correct | 40 ms | 111316 KB | Output is correct |
5 | Correct | 43 ms | 111304 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 41 ms | 111312 KB | Output is correct |
9 | Correct | 42 ms | 111332 KB | Output is correct |
10 | Correct | 41 ms | 111308 KB | Output is correct |
11 | Correct | 41 ms | 111244 KB | Output is correct |
12 | Correct | 41 ms | 111312 KB | Output is correct |
13 | Correct | 47 ms | 111240 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 82 ms | 111244 KB | Output is correct |
2 | Correct | 84 ms | 111352 KB | Output is correct |
3 | Correct | 115 ms | 111312 KB | Output is correct |
4 | Correct | 184 ms | 111364 KB | Output is correct |
5 | Correct | 44 ms | 111308 KB | Output is correct |
6 | Correct | 68 ms | 111348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 111228 KB | Output is correct |
2 | Correct | 44 ms | 111276 KB | Output is correct |
3 | Correct | 43 ms | 111340 KB | Output is correct |
4 | Correct | 42 ms | 111228 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 111308 KB | Output is correct |
2 | Correct | 40 ms | 111344 KB | Output is correct |
3 | Correct | 47 ms | 111268 KB | Output is correct |
4 | Correct | 40 ms | 111316 KB | Output is correct |
5 | Correct | 43 ms | 111304 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 41 ms | 111312 KB | Output is correct |
9 | Correct | 42 ms | 111332 KB | Output is correct |
10 | Correct | 41 ms | 111308 KB | Output is correct |
11 | Correct | 41 ms | 111244 KB | Output is correct |
12 | Correct | 41 ms | 111312 KB | Output is correct |
13 | Correct | 47 ms | 111240 KB | Output is correct |
14 | Correct | 82 ms | 111244 KB | Output is correct |
15 | Correct | 84 ms | 111352 KB | Output is correct |
16 | Correct | 115 ms | 111312 KB | Output is correct |
17 | Correct | 184 ms | 111364 KB | Output is correct |
18 | Correct | 44 ms | 111308 KB | Output is correct |
19 | Correct | 68 ms | 111348 KB | Output is correct |
20 | Correct | 45 ms | 111228 KB | Output is correct |
21 | Correct | 44 ms | 111276 KB | Output is correct |
22 | Correct | 43 ms | 111340 KB | Output is correct |
23 | Correct | 42 ms | 111228 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 156 ms | 111352 KB | Output is correct |
26 | Correct | 291 ms | 111356 KB | Output is correct |
27 | Correct | 74 ms | 111436 KB | Output is correct |
28 | Correct | 116 ms | 111308 KB | Output is correct |
29 | Correct | 154 ms | 111308 KB | Output is correct |
30 | Correct | 195 ms | 111436 KB | Output is correct |