# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140826 | Shelby | Kitchen (BOI19_kitchen) | C++11 | 42 ms | 848 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |