Advertisement

一本通 第十二章 第二节:例9.16 分组背包问题

阅读量:

题目描述

复制代码
    #include <bits/stdc++.h>
    using namespace std;
    const int MaxM = 210;	// 总体积
    const int MaxN = 100;	
    int v[MaxN][MaxN];		// v[i][k] 表示第i组物品,的第k件的体积
    int w[MaxN][MaxN];		// w[i][k] 表示第i组物品,的第k件的重量
    int m, n, t;
    int cnt[MaxN];			// cnt[i] 表示第i组物品的数量
    int f[MaxM];
    
    int main()
    {
    	scanf("%d%d%d", &m, &n, &t);
    	int x, y, z;
    	for(int i = 1; i <= n; ++i)
    	{
    		scanf("%d%d%d", &x, &y, &z);	
    		cnt[z]++;
    		v[z][cnt[z]] = x;
    		w[z][cnt[z]] = y;
    	}
    	memset(f, 0xcf, sizeof f);
    	f[0] = 0;
    	for(int i = 1; i <= t

全部评论 (0)

还没有任何评论哟~