| 比赛 | 20101119 | 评测结果 | AWWWWWWWWW | 
    | 题目名称 | 奥运会 | 最终得分 | 10 | 
    | 用户昵称 | .Xmz | 运行时间 | 0.000 s | 
    | 代码语言 | C++ | 内存使用 | 0.00 MiB | 
    | 提交时间 | 2010-11-19 09:19:04 | 
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cstdlib>
using namespace std;
const int maxans=1000000000;
long long g[16],s[16],b[16];
int n;
long long pg,ps,pb;
bool ok()
{
	for (int i=2;i<=n;i++)
	{
		if (g[i]*pg+s[i]*ps+b[i]*pb>g[1]*pg+s[1]*ps+b[1]*pb) return false;
	}
	return true;
}
bool efb(int l,int r)
{
	if (l==r)
	{
		pb=l;
		return ok();
	}
	pb=(l+r)/2;
	if (ok()) return efb(l,pb);
	return efb(pb+1,r);
}
bool efs(int l,int r)
{
	if (l==r)
	{
		ps=l;
		return efb(1,ps);
	}
	ps=(l+r)/2;
	if (efb(1,ps)) return efs(l,ps);
	return efs(ps+1,r);
}
bool efg(int l,int r)
{
	if (l==r)
	{
		pg=l;
		return efs(1,pg);
	}
	pg=(l+r)/2;
	if (efs(1,pg)) return efg(l,pg);
	return efg(pg+1,r);
}
int main()
{
	freopen("olympic.in","r",stdin);
	freopen("olympic.out","w",stdout);
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld%lld%lld",g+i,s+i,b+i);
	}
	efg(1,maxans);
	printf("%lld %lld %lld\n",pg,ps,pb);
	return 0;
}