简单背包
#include <stdio.h>
int arr[10100];
int tab[10100];
int solve_dp( int n, int m ) {
int i,j;
for ( i=0;i<n;i++ ) {
for ( j=m;j>=arr[i];j-- ) {
if ( arr[i]+tab[j-arr[i]]>tab[j] )
tab[j]=arr[i]+tab[j-arr[i]];
}
}
return tab[m];
}
int main()
{
int t,n,m,i;
int result;
scanf( "%d",&t );
while ( t-- ) {
scanf( "%d%d",&n,&m );
for ( i=0;i<n;i++ ) {
scanf("%d",&arr[i]);
tab[i]=0;
}
tab[i+1]=0;
result = solve_dp(n,m);
printf( "%d\n",result );
}
return 0;
}