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 <stdio.h>
int n,m;
int ba[110],data[110];
int table[10000010];
int main()
{
int i,a;
int sum=0;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++)
{
scanf("%d ",&ba[i]);
}
for(i=1;i<=n;i++)
{
scanf("%d ",&data[i]);
sum+=data[i];
}
/*if(n*m<=80000000)
{
for(i=1;i<=m;i++)
{
table[i]=sum;
}
table[0]=0;
for(i=1;i<=n;i++)
{
for(a=m;a>=0;a--)
{
if(a+ba[i]<=m && table[a+ba[i]]>table[a]+data[i])
{
table[a+ba[i]]=table[a]+data[i];
}
}
}
printf("%d\n",table[m]);
}
else*/
{
table[0]=1;
for(i=1;i<=n;i++)
{
for(a=sum;a>=0;a--)
{
if(table[a] && table[a+data[i]]<table[a]+ba[i])
{
table[a+data[i]]=table[a]+ba[i];
}
}
}
for(i=0;i<=sum;i++)
{
if(table[i]-1>=m)
{
printf("%d\n",i);
break;
}
}
}
return 0;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |