蒟蒻的一片红
查看原帖
蒟蒻的一片红
255540
Her_Lingxiao楼主2020/7/14 20:27

应该是正常解法,但是在Ubuntu20.04下不给输出,给了也是0

#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
const int Maxn = 1e3 + 3;
int dp[101];
int t, m, n;
int things[Maxn][Maxn];
int main()
{
	
	memset(things, 0, Maxn);
	scanf("%d %d %d", &t, &m, &n);
	for(int i = 1; i <= t; i++)
	{
		for(int j = 1; i <= n; i++)
		{
			scanf("%d", &things[i][j]);
		}
	}
	
	for(int x = 1; x <= t; x++)
	{
		memset(dp, 0, Maxn);
		for(int y = 1; y <= m; y++)//钱 
		{
			for(int z = 1; z <= n; z++)
			{
				if(y >= things[x][z])
					dp[y] = max(dp[y], dp[y - things[x][z]] + (things[x + 1][z] - things[x][z]));
			}
		}
		m += dp[m];
	}
	printf("%d\n", m);
	
	return 0;
}
2020/7/14 20:27
加载中...