比赛 |
Asm.Def战记之圣地亚哥“杯2015 |
评测结果 |
AWWWWETTTT |
题目名称 |
Asm.Def的枪榴弹 |
最终得分 |
10 |
用户昵称 |
WINAPI |
运行时间 |
4.599 s |
代码语言 |
C++ |
内存使用 |
50.52 MiB |
提交时间 |
2015-10-31 11:54:35 |
显示代码纯文本
#include<cstdio>
#include<cstring>
int a[16],b[16],c[16],d[16],e[16];
int n;
int max=-1;
int vis[16]={0};
void init()
{
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]);
}
int judge(int k0,int k1,int k2,int i)
{
if(k0>=a[i])
{
if(k1>=b[i]) return 1;
else if(k1+k2>=b[i]) return 2;
else return 0;
}
else
{
if(k0+k2>=a[i])
if(k1>=b[i]) return 3;
else if(k0+k2-a[i]+k1>=b[i]) return 4;
else return 0;
else return 0;
}
}
int dfs(int x,int k0,int k1,int k2)
{
int i,j,ok=0;
for(i=1;i<=n;i++)
{
if(vis[i]!=1)
{
if(judge(k0,k1,k2,i)==1) {ok=1;vis[i]=1;dfs(i,k0-a[i]+c[i],k1-b[i]+d[i],k2+e[i]);vis[i]=0;}
else if(judge(k0,k1,k2,i)==2){ok=1;vis[i]=1;dfs(i,k0-a[i]+c[i],0+d[i],k1+k2-b[i]+e[i]);vis[i]=0;}
else if(judge(k0,k1,k2,i)==3){ok=1;vis[i]=1;dfs(i,0+c[i],k1-b[i]+d[i],k0+k2-a[i]+e[i]);vis[i]=0;}
else if(judge(k0,k1,k2,i)==4){ok=1;vis[i]=1;dfs(i,0+c[i],0+d[i],k1+k2+k0-a[i]-b[i]+e[i]);vis[i]=0;}
}
}
if(ok==0) {
if(k0+k1+k2>max) max=k0+k1+k2;
}
return 0;
}
int main()
{
freopen("asm_grenade.in","r",stdin);
freopen("asm_grenade.out","w",stdout);
scanf("%d",&n);
init();
int k0,k1,k2;
scanf("%d%d%d",&k0,&k1,&k2);
for(int i=1;i<=n;i++)
dfs(i,k0,k1,k2);
printf("%d",max);
return 0;
}