比赛 不平凡的世界 评测结果 AAAAAAAAAAT
题目名称 不平凡的boss 最终得分 90
用户昵称 Mayuri 运行时间 1.253 s
代码语言 C++ 内存使用 1.84 MiB
提交时间 2017-09-05 19:36:35
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;

#define ll long long
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))

const int maxN=100101;
const int inf=2147483647;

class Data
{
public:
	int now;
	int num;
	int A[4];
};

int n;
int Ans;
int Att[maxN][4];

int read();
void dfs(int now,int A,int B,int C);

int main()
{
	freopen("playwithboss.in","r",stdin);
	freopen("playwithboss.out","w",stdout);
	n=read();
	for (int i=1;i<=n;i++)
	{
		Att[i][1]=read();
		Att[i][2]=read();
		Att[i][3]=read();
	}
	Ans=inf;
	dfs(1,0,0,0);
	cout<<Ans<<endl;
	fclose(stdin);
	fclose(stdout);
	return 0;
}

int read()
{
	int x=0;
	int k=1;
	char ch=getchar();
	while (((ch>'9')||(ch<'0'))&&(ch!='-'))
		ch=getchar();
	if (ch=='-')
	{
		k=-1;
		ch=getchar();
	}
	while ((ch>='0')&&(ch<='9'))
	{
		x=x*10+ch-48;
		ch=getchar();
	}
	return x*k;
}

void dfs(int now,int A,int B,int C)
{
	if (A+B+C>=Ans)
		return;
	if (now==n+1)
	{
		Ans=min(Ans,A+B+C);
		return;
	}
	if ((A>=Att[now][1])||(B>=Att[now][2])||(C>=Att[now][3]))
	{
		dfs(now+1,A,B,C);
		return;
	}
	dfs(now+1,Att[now][1],B,C);
	dfs(now+1,A,Att[now][2],C);
	dfs(now+1,A,B,Att[now][3]);
	return;
}