感觉框架应该没错,但是只有30分
查看原帖
感觉框架应该没错,但是只有30分
255540
Her_Lingxiao楼主2020/6/13 14:46
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = int(1e3) + 3;
long long f[maxn][maxn];
struct player
{
	int lose;
	int win;
	int energy;
}pl[maxn];
int main()
{
	int n, x;
	scanf("%d %d", &n, &x);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d %d %d", &pl[i].lose, &pl[i].win, &pl[i].energy);
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= x; j++)
		{
			if(j < pl[i].energy)
				f[i][j] = f[i - 1][j] + pl[i].lose;
			else
			{
				f[i][j] = max(f[i - 1][j] + pl[i].lose, f[i - 1][j - pl[i].energy] + pl[i].win);
			}
		}
	}
	#if 1
	printf("\n\n");
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= x; j++)
		{
			printf("%d ", f[i][j]);
		}
		printf("\n");
	}
	printf("\n\n");
	#endif
	printf("%lld", f[n][x] * 5); 

	return 0;
}
2020/6/13 14:46
加载中...