AcWing 1019. 庆功会 多重背包求max

//多重背包    max
#include <iostream>
using namespace std;
const int N = 6010;
int n, m;
int f[N];
int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i ++ ) {
        int v, w, s;
        cin >> v >> w >> s;
        for (int j = m; j >= 0; j -- )
            for (int k = 0; k <= s && k * v <= j; k ++ )
                f[j] = max(f[j], f[j - k * v] + k * w);
    }
    cout << f[m] << endl;
    return 0;
}

 

 

posted @ 2019-12-04 02:21  晴屿  阅读(140)  评论(0编辑  收藏  举报