2020杭电多校第二场 Lead of Wisdom

第十题:Lead of Wisdom

题目:

In an online game, “Lead of Wisdom” is a place where the lucky player can randomly get powerful items.

There are k types of items, a player can wear at most one item for each type. For the i-th item, it has four attributes ai,bi,ci and di. Assume the set of items that the player wearing is S, the damage rate of the player DMG can be calculated by the formula:

DMG=(100+∑i∈Sai)(100+∑i∈Sbi)(100+∑i∈Sci)(100+∑i∈Sdi)

Little Q has got n items from “Lead of Wisdom”, please write a program to help him select which items to wear such that the value of DMG is maximized.

思路

不要这么暴力嘛qaq 哭唧唧~~

代码

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;

const int N=110;

int n,m;
int cnt[N],nxt[N];
ll e[N][N][5];
ll ans;


void dfs(int x,int a,int b,int c,int d)
{
	if(x>m)
	{
		ll temp=1LL*a*b*c*d;
		ans=max(ans,temp);
		return ;
	}
	
	if(!cnt[x])
	{
		dfs(nxt[x],a,b,c,d);
		return ;
	}
	
	int n=cnt[x];
	for(int i=1;i<=n;i++)
	{
		dfs(x+1,a+e[x][i][0],b+e[x][i][1],c+e[x][i][2],d+e[x][i][3]);
	}
}

int main()
{
	//freopen("test.in","r",stdin);//设置 cin scanf 这些输入流都从 test.in中读取
    //freopen("test.out","w",stdout);//设置 cout printf 这些输出流都输出到 test.out里面去
//	ios::sync_with_stdio(false);
//	cin.tie(0),cout.tie(0);
	int T;
	cin>>T;
	while(T--)
	{
		scanf("%d%d",&n,&m);
		int x;
		for(int i=0;i<=n;i++) cnt[i]=0;
		for(int j=0;j<n;j++)
		{
			scanf("%d",&x);
			cnt[x]++;
			for(int i=0;i<4;i++)
			{
				scanf("%d",&e[x][cnt[x]][i]);
			}
		}
		x=m+1;
		for(int i=m;i;i--)
		{
			nxt[i]=x;
			if(cnt[i]) x=i;
		}
		ans=100*100*100*100;
		dfs(1,100,100,100,100);
		cout<<ans<<endl;
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值