0/1背包问题
int maxx=0;
for(int i=1;i<=res.size();i++){
for(int j=1;j<=a;j++){
if(res[i-1].price>j){
dp[i][j]=dp[i-1][j];
}else{//放与不放,dp[i-1][j-res[i-1].price]:放入后,在j-res[i-1].price容量的最大评价
dp[i][j]=max(dp[i-1][j],dp[i-1][j-res[i-1].price]+res[i-1].score);
}
maxx=max(dp[i][j],maxx);
}
}
cout<<maxx<<endl;
}
}// 64 位输出请用 printf("%lld")