Create 3251.cpp

pull/10/head
Kirigaya Kazuto 2016-05-01 14:26:34 +08:00
parent ff8c1e167d
commit 949a142b95
1 changed files with 65 additions and 0 deletions

65
SDUTOJ/3251.cpp Normal file
View File

@ -0,0 +1,65 @@
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
struct STX
{
double height,weight;
};
bool comp(const STX& a,const STX& b)
{
return a.height<b.height;
}
int main()
{
int t;
scanf("%d",&t);
for(int tt=0;tt<t;tt++)
{
int n;
scanf("%d",&n);
vector<STX> vec;
for(int i=0;i<n;i++)
{
STX s;
scanf("%lf %lf",&s.height,&s.weight);
vec.push_back(s);
}
sort(vec.begin(),vec.end(),comp);
double red=0;
double blue=0;
for(int i=0;i<n;i++)
{
//printf("## vec.at(i).height= %f\n",vec.at(i).height);
if((i+1)%2)
{
//printf("## red\n");
red+=vec.at(i).weight;
}
else
{
//printf("## blue\n");
blue+=vec.at(i).weight;
}
}
if(blue>red)
{
printf("blue\n");
}
else if(blue<red)
{
printf("red\n");
}
else
{
printf("fair\n");
}
}
return 0;
}