#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
40152 KB |
Output is correct |
2 |
Correct |
0 ms |
40152 KB |
Output is correct |
3 |
Correct |
0 ms |
40152 KB |
Output is correct |
4 |
Correct |
0 ms |
40152 KB |
Output is correct |
5 |
Correct |
0 ms |
40152 KB |
Output is correct |
6 |
Correct |
0 ms |
40152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
40152 KB |
Output is correct |
2 |
Correct |
0 ms |
40152 KB |
Output is correct |
3 |
Correct |
0 ms |
40152 KB |
Output is correct |
4 |
Correct |
0 ms |
40152 KB |
Output is correct |
5 |
Correct |
0 ms |
40152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
40152 KB |
Output is correct |
2 |
Correct |
0 ms |
40152 KB |
Output is correct |
3 |
Correct |
0 ms |
40152 KB |
Output is correct |
4 |
Correct |
0 ms |
40152 KB |
Output is correct |
5 |
Correct |
0 ms |
40152 KB |
Output is correct |
6 |
Correct |
0 ms |
40152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
40152 KB |
Output is correct |
2 |
Correct |
0 ms |
40152 KB |
Output is correct |
3 |
Correct |
0 ms |
40152 KB |
Output is correct |
4 |
Correct |
0 ms |
40152 KB |
Output is correct |
5 |
Correct |
0 ms |
40152 KB |
Output is correct |
6 |
Correct |
0 ms |
40152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
40152 KB |
Output is correct |
2 |
Correct |
0 ms |
40152 KB |
Output is correct |
3 |
Correct |
0 ms |
40152 KB |
Output is correct |
4 |
Correct |
0 ms |
40152 KB |
Output is correct |
5 |
Correct |
0 ms |
40152 KB |
Output is correct |
6 |
Correct |
0 ms |
40152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
40152 KB |
Output is correct |
2 |
Correct |
0 ms |
40152 KB |
Output is correct |
3 |
Correct |
0 ms |
40152 KB |
Output is correct |
4 |
Correct |
0 ms |
40152 KB |
Output is correct |
5 |
Correct |
0 ms |
40152 KB |
Output is correct |
6 |
Correct |
0 ms |
40152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
40152 KB |
Output is correct |
2 |
Correct |
0 ms |
40152 KB |
Output is correct |
3 |
Correct |
0 ms |
40152 KB |
Output is correct |
4 |
Correct |
0 ms |
40152 KB |
Output is correct |