比赛 不平凡的世界 评测结果 AAAAAAAWWW
题目名称 不平凡的boss 最终得分 70
用户昵称 dydxh 运行时间 1.708 s
代码语言 C++ 内存使用 1.46 MiB
提交时间 2015-11-05 11:52:10
显示代码纯文本
/*
Problem:cogs2097;
Language:c++;
by dydxh;
2015.11.05;
*/
#include<iostream>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<utility>
#include<ctime>
#include<cstdlib>
#include<bitset>
#include<string>
#define ll long long
#define ull unsigned long long
using namespace std;
const int oo=2000000000;
const int maxn=100005;
int n;
double T=0.67;
struct Monster{
	int A,B,C;
}p[maxn];
inline int read(){
	int x=0;bool flag=0;char ch=getchar();
	while(ch>'9' || ch<'0') {if(ch=='-') flag=1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return flag?-x:x;
}
void Step1(){
	int ans=oo;
	for(int A=0;A<=300;A++)
		for(int B=0;B<=300;B++){
			int C=0;
			for(int i=1;i<=n;i++){
				if(p[i].A<=A) continue;
				if(p[i].B<=B) continue;
				if(C<p[i].C) C=p[i].C;
			}
			if(A+B+C<ans) ans=A+B+C;
		}
	printf("%d\n",ans);
}
bool mycmp1(Monster a,Monster b){
	return a.A<b.A;
}
void Step2(){
	sort(p+1,p+1+n,mycmp1);
	int Max_B=0,ans=oo;
	for(int i=n;i>=0;i--){
		int Max_A=p[i].A;
		if(Max_B<p[i+1].B) Max_B=p[i+1].B;
		if(Max_B+Max_A<ans) ans=Max_A+Max_B;
	}
	printf("%d\n",ans);
}
void Step3(){
	int Max_A=0,Max_B=0,Max_C=0;
	for(int i=1;i<=n;i++){
		if(p[i].A<=Max_A || p[i].B<=Max_B || p[i].C<=Max_C)
			continue;
		if(p[i].A==p[i].B && p[i].A==p[i].C){
			if(Max_A<Max_C && Max_A<Max_B)
				Max_A=p[i].A;
			else if(Max_B<Max_C && Max_B<Max_A)
				Max_B=p[i].B;
			else Max_C=p[i].C;
		}
		else if(p[i].A==p[i].B && p[i].C<p[i].A)
			Max_C=p[i].C;
		else if(p[i].B==p[i].C && p[i].A<p[i].C)
			Max_A=p[i].A;
		else if(p[i].A==p[i].C && p[i].B<p[i].A)
			Max_B=p[i].B;
		else{
			if(1.0*(rand()%10000)/10000>T){
				if(Max_A<=Max_C && Max_A<=Max_B)
					Max_A=p[i].A;
				else if(Max_B<=Max_C && Max_B<=Max_A)
					Max_B=p[i].B;
				else Max_C=p[i].C;
				T*=1.02;
			}
			else{
				if(Max_A>=Max_C && Max_A>=Max_B)
					Max_A=p[i].A;
				else if(Max_B>=Max_C && Max_B>=Max_A)
					Max_B=p[i].B;
				else Max_C=p[i].C;
			}
		}
	}
	printf("%d\n",Max_A+Max_B+Max_C);
}
int main()
{
	srand(time(0));
	//freopen("cc.in","r",stdin);
	freopen("playwithboss.in","r",stdin);
	freopen("playwithboss.out","w",stdout);
	n=read();
	int IFTWO=true;
	for(int i=1;i<=n;i++){
		p[i].A=read(),p[i].B=read(),p[i].C=read();
		if(p[i].C!=100000000) IFTWO=false;
	}
	if(!IFTWO && n<=300) Step1();
	else if(IFTWO) Step2();
	else Step3();
	return 0;
}