比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 WWWWTWTTWT
题目名称 Asm.Def的枪榴弹 最终得分 0
用户昵称 sxysxy 运行时间 4.008 s
代码语言 C++ 内存使用 0.28 MiB
提交时间 2015-10-31 11:37:13
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#define MAXN (16)
#define MAXN2 (60)
using namespace std;

int N;
int a[MAXN];    //jiqiren
int b[MAXN];	//paotai

int c[MAXN];	//jia 	-jiqiren
int d[MAXN];	//yi  	-paotai
int e[MAXN];	//bing  -jiqiren or paotai
int k0,k1,k2;
//int note[MAXN][MAXN2][MAXN2][MAXN2];
bool vis[MAXN];

void read()
{
	int i;
	for(i = 1; i <= N; i++)
		scanf("%d", a+i);
	
	for(i = 1; i <= N; i++)
		scanf("%d", b+i);
	
	for(i = 1; i <= N; i++)
		scanf("%d", c+i);
	
	for(i = 1; i <= N; i++)
		scanf("%d", d+i);
	
	for(i = 1; i <= N; i++)
		scanf("%d", e+i);
	
	scanf("%d %d %d", &k0, &k1, &k2);
}

/*
int judge(int idx,int jia,int yi,int bing)
{
	int u,t;
	
	int rb,pt;
	int bj,by,bb;
	
	rb = a[idx];
	pt = b[idx];
	bj = c[idx];
	by = d[idx];
	bb = e[idx];
	
	if(bj > rb && by > pt)return 1;
	else{
		
	}
}
*/
int rrr = -1;
void dfs(int n,int jia,int yi,int bing)
{
	/*
	int g,h,j;
	if(n < 1)
	{
		return 0;
	}
	if(note[n][jia][yi][bing] >= 0)return note[n][jia][yi][bing];
	if(c[n]+d[n]+e[n] <= a[n]+b[n])return note[n][jia][yi][bing] = dfs(n-1,jia,yi,bing);
	else
	{
		g = jia;
		h = yi;
		j = bing;
		if(jia < a[n])
		{
			if(j - (a[n]-jia) < 0)return note[n][jia][yi][bing] = dfs(n-1,jia,yi,bing);
			//g += (a[n] - jia);
			g = 0;
			j -= (a[n] - jia);
		}else if(jia >= a[n])g -= a[n];
		
		if(yi < b[n])
		{
			if(j - (b[n]-yi) < 0)return note[n][jia][yi][bing] = dfs(n-1,jia,yi,bing);
			//h += (b[n] - yi);       
			h = 0;
			j -= (b[n] - yi);
		}else if(yi >= b[n])h -= b[n];
		
		if(g < 0 || h < 0 || j < 0)return note[n][jia][yi][bing] = dfs(n-1,jia,yi,bing);
		g += c[n];
		h += d[n];
		j += e[n];
		
		return note[n][jia][yi][bing] = max(dfs(n-1,jia,yi,bing), dfs(n-1,g,h,j)+g+h+j);
	}*/
	if(n == N)
	{
		rrr = max(rrr,jia+yi+bing);
		return;
	}
	int i;
	int g,h,j;
	int k,m;
	for(i = 1; i <= n; i++)
	{
		if(vis[n])continue;
		g = jia;
		h = yi;
		j = bing;
		if(jia < a[n])
		{
			if(j - (a[n]-jia) < 0)return;
			//g += (a[n] - jia);
			g = 0;
			j -= (a[n] - jia);
		}else if(jia >= a[n])g -= a[n];
		
		if(yi < b[n])
		{
			if(j - (b[n]-yi) < 0)return;
			//h += (b[n] - yi);       
			h = 0;
			j -= (b[n] - yi);
		}else if(yi >= b[n])h -= b[n];
		
		g += c[n];
		h += d[n];
		j += e[n];
		if(g < 0 || h < 0 || j < 0)return;
		
		for(k = 1; k <= N; k++)
		{
			vis[n] = true;
			dfs(k,g,h,j);
			vis[n] = false;
		}
	}
}

void solve()
{
	//memset(note,-1,sizeof(note));
	dfs(1,k0,k1,k2);
	printf("%d\n",rrr);
	/*
	int i;
	int u,t;
	int rb,pt;
	int bj,by,bb;
	
	for(i = 1; i <= n; i++)
	{
		rb = a[i];
		pt = b[i];
		bj = c[i];
		by = d[i];
		bb = e[i];
		
		if(bj > rb && by > pt)
		{
			k0 += bj-rb;
			k1 += by-pt;
			k2 += bb;
		}else
		{
			if(bj <= rb)
			{
				u = rb - bj;
				t = bb;
				t -= u;
				
			}
		}
	}
	cout << k0+k1+k2 << endl;
	*/
}

int main()
{
	freopen("asm_grenade.in", "r", stdin);
	freopen("asm_grenade.out", "w", stdout);
	cin >> N;
	read();
	solve();
	return 0;
}