# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
216132 | 2020-03-26T18:29:04 Z | MKopchev | Kitchen (BOI19_kitchen) | C++14 | 17 ms | 768 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=3e2+42,inf=1e9; void no() { printf("Impossible"); exit(0); } int take_min(int a,int b) { if(a==-1)return b; return min(a,b); } int filled[nmax*nmax]; int n,m,k; int main() { scanf("%i%i%i",&n,&m,&k); int sum=0,dish; for(int i=1;i<=n;i++) { scanf("%i",&dish); if(dish<k)no(); sum=sum+dish; } for(int i=1;i<nmax*nmax;i++)filled[i]=-inf; int chef,ret=-1,total=0; for(int i=1;i<=m;i++) { scanf("%i",&chef); total=total+chef; for(int bought=total;bought>=chef;bought--) { int can_buy=min(n,chef); filled[bought]=max(filled[bought],filled[bought-chef]+can_buy); } //for(int bought=0;bought<=total;bought++)cout<<filled[bought]<<" ";cout<<endl; } if(total<sum)no(); //cout<<"sum= "<<sum<<endl; for(int i=sum;i<=total;i++) if(filled[i]>=k*n)ret=take_min(ret,i-sum); if(ret==-1)no(); printf("%i\n",ret); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 4 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 4 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
9 | Correct | 5 ms | 768 KB | Output is correct |
10 | Correct | 5 ms | 768 KB | Output is correct |
11 | Correct | 5 ms | 768 KB | Output is correct |
12 | Correct | 5 ms | 768 KB | Output is correct |
13 | Correct | 5 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 768 KB | Output is correct |
2 | Correct | 11 ms | 768 KB | Output is correct |
3 | Correct | 12 ms | 768 KB | Output is correct |
4 | Correct | 17 ms | 768 KB | Output is correct |
5 | Correct | 16 ms | 768 KB | Output is correct |
6 | Correct | 10 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 4 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
9 | Correct | 5 ms | 768 KB | Output is correct |
10 | Correct | 5 ms | 768 KB | Output is correct |
11 | Correct | 5 ms | 768 KB | Output is correct |
12 | Correct | 5 ms | 768 KB | Output is correct |
13 | Correct | 5 ms | 768 KB | Output is correct |
14 | Correct | 13 ms | 768 KB | Output is correct |
15 | Correct | 11 ms | 768 KB | Output is correct |
16 | Correct | 12 ms | 768 KB | Output is correct |
17 | Correct | 17 ms | 768 KB | Output is correct |
18 | Correct | 16 ms | 768 KB | Output is correct |
19 | Correct | 10 ms | 768 KB | Output is correct |
20 | Correct | 5 ms | 768 KB | Output is correct |
21 | Correct | 5 ms | 768 KB | Output is correct |
22 | Correct | 5 ms | 768 KB | Output is correct |
23 | Correct | 5 ms | 768 KB | Output is correct |
24 | Correct | 5 ms | 256 KB | Output is correct |
25 | Correct | 11 ms | 768 KB | Output is correct |
26 | Correct | 12 ms | 768 KB | Output is correct |
27 | Correct | 7 ms | 768 KB | Output is correct |
28 | Correct | 11 ms | 768 KB | Output is correct |
29 | Correct | 13 ms | 768 KB | Output is correct |
30 | Correct | 17 ms | 768 KB | Output is correct |