# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
216120 | 2020-03-26T18:18:38 Z | MKopchev | Kitchen (BOI19_kitchen) | C++14 | 29 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 pay[nmax*nmax];//least money to pay for i of the first minutes 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 j=1;j<nmax*nmax;j++)pay[j]=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>=0;bought--) { int can_buy=min(n,min(chef,bought)); pay[bought]=min(pay[bought],pay[bought-can_buy]+chef); } } if(total<sum)no(); for(int i=k*n;i<=total;i++) if(pay[i]>=sum&&pay[i]<inf)ret=take_min(ret,pay[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 | Incorrect | 5 ms | 768 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Incorrect | 5 ms | 768 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 768 KB | Output is correct |
2 | Correct | 18 ms | 768 KB | Output is correct |
3 | Correct | 20 ms | 768 KB | Output is correct |
4 | Correct | 29 ms | 768 KB | Output is correct |
5 | Correct | 29 ms | 760 KB | Output is correct |
6 | Correct | 15 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 | 4 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Incorrect | 5 ms | 768 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |