应该是正常解法,但是在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;
}