http://acm.hdu.edu.cn/showproblem.php?pid=2602
#include<bits/stdc++.h> #define maxn 100004 int v[maxn]; int dp[maxn]; int weigh[maxn]; int n,V,t; using namespace std; int main() { cin>>t; while(t--) { cin>>n>>V; for(int i=0; i<n; i++) cin>>weigh[i]; for(int i=0; i<n; i++) cin>>v[i]; memset(dp,0,sizeof(dp)); for(int i=0; i<n; i++) for(int j=V; j>=v[i]; j--) dp[j]=max(dp[j],dp[j-v[i]]+weigh[i]); cout<<dp[V]<<endl; } return 0; }