1269:【例9.13】庆功会
1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 5 const int N=505; 6 int a[N],b[N],c[N],f[N][6005]; 7 int main(){ 8 int m,n; 9 cin>>n>>m; 10 for(int i=1;i<=n;i++)cin>>a[i]>>b[i]>>c[i]; 11 for(int i=1;i<=n;i++) 12 for(int j=1;j<=m;j++) 13 for(int k=0;k<=j/a[i]&&k<=c[i];k++) 14 f[i][j]=max(f[i][j],b[i]*k+f[i-1][j-a[i]*k]); 15 cout<<f[n][m]; 16 return 0; 17 }