动态规划背包实例--King’s Ruins

动态规划背包实例--King’s Ruins_第1张图片

#include
using namespace std;
typedef long long LL;
const int N=2e5+100;
LL w[N];
LL g[N];
LL x[N];
LL f[N];
LL l[N];
LL dp[N];
LL v[N];
void solve()
{
	memset(dp,0,sizeof(dp));
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>g[i]>>x[i]>>f[i]>>l[i]>>v[i];
		dp[i]=v[i];
	}
	cout<=1;j--)
		{
			if(w[i]>=w[j]&&g[i]>=g[j]&&x[i]>=x[j]&&f[i]>=f[j]&&l[i]>=l[j])
			{
				dp[i]=max(dp[i],v[i]+dp[j]);
            }
		}
		cout<>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

 

你可能感兴趣的:(ACM,动态规划,算法)