比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 AAAAAAAAAA
题目名称 Asm.Def的枪榴弹 最终得分 100
用户昵称 欧鹰123 运行时间 0.005 s
代码语言 C++ 内存使用 13.66 MiB
提交时间 2019-10-23 17:37:26
显示代码纯文本
#include<bits/stdc++.h>

using namespace std;

struct node{
	int peo,pao,jia,yi,bing,ans;
}room[20];

int peo[5],ans,n,vis[20];

inline int read()
{
	int x=1,w=0;
	
	char ch=getchar();
	
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') x=-1;
	
	for(;ch>='0'&&ch<='9';ch=getchar()) w=w*10+ch-'0';
	
	return w*x;
}

bool check()
{
	int sum=0;
	
	for(int i=1;i<=n;i++) if(vis[i]==0&&room[i].ans>0) sum+=room[i].ans;
	
	if(peo[1]+peo[2]+peo[3]+sum<=ans) return true;
	
	return false;
}

void dfs()
{
	if(check()) return;
	
	ans=max(peo[1]+peo[2]+peo[3],ans);
	
	for(int i=n;i>=1;i--)
	{
		if(vis[i]==1) continue;
		
		int a1=peo[1],a2=peo[2],a3=peo[3];
		
		if(room[i].peo>peo[1]) peo[3]=peo[3]-(room[i].peo-peo[1]);

		if(room[i].pao>peo[2]) peo[3]=peo[3]-(room[i].pao-peo[2]);
		
		if(peo[3]<0)
		{
			peo[3]=a3;
			
			continue;
		}
		
		peo[1]=max(0,peo[1]-room[i].peo);
		
		peo[2]=max(0,peo[2]-room[i].pao);
		
		vis[i]=1;
		
		peo[1]+=room[i].jia;peo[2]+=room[i].yi;peo[3]+=room[i].bing;
		
		dfs();
		
		vis[i]=0;
		
		peo[1]=a1;peo[2]=a2;peo[3]=a3;
	}
}

int main()
{
	freopen("asm_grenade.in","r",stdin);
	
	freopen("asm_grenade.out","w",stdout);
	
	n=read();
	
	for(int i=1;i<=n;i++) room[i].peo=read(),room[i].ans-=room[i].peo;
	
	for(int i=1;i<=n;i++) room[i].pao=read(),room[i].ans-=room[i].pao;
	
	for(int i=1;i<=n;i++) room[i].jia=read(),room[i].ans+=room[i].jia;
	
	for(int i=1;i<=n;i++) room[i].yi=read(),room[i].ans+=room[i].yi;
	
	for(int i=1;i<=n;i++) room[i].bing=read(),room[i].ans+=room[i].bing;
	
	peo[1]=read();peo[2]=read();peo[3]=read();
	
	ans=peo[1]+peo[2]+peo[3];
	
	for(int i=n;i>=1;i--)
	{
		int a1=peo[1],a2=peo[2],a3=peo[3];
		
		if(room[i].peo>peo[1]) peo[3]=peo[3]-(room[i].peo-peo[1]);

		if(room[i].pao>peo[2]) peo[3]=peo[3]-(room[i].pao-peo[2]);
		
		if(peo[3]<0)
		{
			peo[3]=a3;
			
			continue;
		}
		
		peo[1]=max(0,peo[1]-room[i].peo);
		
		peo[2]=max(0,peo[2]-room[i].pao);
		
		vis[i]=1;
		
		peo[1]+=room[i].jia;peo[2]+=room[i].yi;peo[3]+=room[i].bing;
		
		dfs();
		
		vis[i]=0;
		
		peo[1]=a1;peo[2]=a2;peo[3]=a3;
	}
	
	cout<<ans;
	
	return 0;
}