比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 AAAATTTTTT
题目名称 Asm.Def的枪榴弹 最终得分 40
用户昵称 ifAandBisC 运行时间 6.148 s
代码语言 C++ 内存使用 0.28 MiB
提交时间 2015-10-31 11:12:27
显示代码纯文本
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define iii 100

using namespace std;
int n,A,B,C,ans;
int rob[iii],pwd[iii];
int ina[iii],inb[iii],inc[iii];
int vis[iii];

void in_put ()
{
	memset (vis,0,sizeof(vis));
	scanf ("%d",&n);
	for (int i=1;i<=n;i++) scanf ("%d",&rob[i]);
	for (int i=1;i<=n;i++) scanf ("%d",&pwd[i]);
	for (int i=1;i<=n;i++) scanf ("%d",&ina[i]);
	for (int i=1;i<=n;i++) scanf ("%d",&inb[i]);
	for (int i=1;i<=n;i++) scanf ("%d",&inc[i]);
	scanf ("%d%d%d",&A,&B,&C);
	ans=A+B+C;
}
bool dfs (int a,int b,int c)
{
	ans=max(ans,a+b+c);
	/*for (int i=1;i<=n;i++)if (vis[i]==1)cout<<i<<" ";cout<<endl;
	cout<<a<<" "<<b<<" "<<c<<endl<<endl;*/
	for (int i=1;i<=n;i++)
	if (!vis[i])
	{
		vis[i]=true;
		dfs (a,b,c);
		int ta=a,tb=b,tc=c;
		if (ta<rob[i])
			if (ta+tc<rob[i]) 
			{
				vis[i]=false;
				continue;
			}
			else tc-=rob[i]-ta,ta=0;
		else ta-=rob[i];
		if (tb<pwd[i])
			if (tb+tc<pwd[i]) 
			{
				vis[i]=false;
				continue;
			}
			else tc-=pwd[i]-tb,tb=0;
		else tb-=pwd[i];
		dfs (ta+ina[i],tb+inb[i],tc+inc[i]);
		vis[i]=false;
	}
}
int main ()
{
	freopen ("asm_grenade.in","r",stdin);
	freopen ("asm_grenade.out","w",stdout);
	in_put();
	dfs (A,B,C);
	printf ("%d\n",ans);
	return 0;
}