sdut 3251 Nias and Tug-of-War 模拟
来源:互联网 发布:医院感染管理三级网络 编辑:程序博客网 时间:2024/06/07 06:36
Nias and Tug-of-War
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
Nias is fond of tug-of-war. One day, he organized a tug-of-war game and invited a group of friends to take part in.
Nias will divide them into two groups. The strategy is simple, sorting them into a row according to their height from short to tall, then let them say one and two alternately (i.e. one, two, one, two...). The people who say one are the members of the red team while others are the members of the blue team.
We know that the team which has a larger sum of weight has advantages in the tug-of-war. Now give you the guys' heights and weights, please tell us which team has advantages.
输入
The first line of input contains an integer T, indicating the number of test cases.
The first line of each test case contains an integer N (N is even and 6 ≤ N ≤ 100).
Each of the next N lines contains two real numbers X and Y, representing the height and weight of a friend respectively.
输出
One line for each test case. If the red team is more likely to win, output "red", if the blue team is more likely to win, output "blue". If both teams have the same weight, output "fair".
示例输入
16 170 55 165.3 52.5 180.2 60.3 173.3 62.3 175 57 162.2 50
示例输出
blue
提示
来源
示例程序
- 提交
- 状态
- 讨论
- 省赛水题
#pragma warning(disable:4786)//使命名长度不受限制#pragma comment(linker, "/STACK:102400000,102400000")//手工开栈#include <map>#include <set>#include <queue>#include <cmath>#include <stack>#include <cctype>#include <cstdio>#include <cstring>#include <stdlib.h>#include <iostream>#include <algorithm>#define rd(x) scanf("%d",&x)#define rd2(x,y) scanf("%d%d",&x,&y)#define rd3(x,y,z) scanf("%d%d%d,&x,&y,&z)#define rdl(x) scanf("%I64d,&x);#define rds(x) scanf("%s",x)#define rdc(x) scanf("%c",&x)#define ll long long int#define ull unsigned long long#define maxn 1005#define mod 1000000007#define INF 0x3f3f3f3f //int 最大值#define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;++i)#define MT(x,i) memset(x,i,sizeof(x))#define PI acos(-1.0)#define E exp(1)#define eps 1e-8ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}ll mul(ll a,ll b,ll p){ll sum=0;for(;b;a=(a+a)%p,b>>=1)if(b&1)sum=(sum+a)%p;return sum;}inline void Scan(int &x) { char c;while((c=getchar())<'0' || c>'9');x=c-'0'; while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';}using namespace std;struct N{ double x,y; void in(){cin>>x>>y;} bool operator <(const N &b)const{return this->x<b.x;}}my[maxn];int main(){ int n,loop,cnt=1; scanf("%d",&loop); while(loop--){ scanf("%d",&n); for(int i=0;i<n;++i)my[i].in(); sort(my,my+n); double a=0,b=0; for(int i=0;i<n;i+=2){ a+=my[i].y; b+=my[i+1].y; } if(fabs(a-b)<eps)puts("fair"); else if(a>b)puts("red"); else puts("blue"); } return 0;}
0 0
- sdut 3251 Nias and Tug-of-War 模拟
- Nias and Tug-of-War 拔河比赛
- 2015山东省第六届ACM省赛 Nias and Tug-of-War
- 第六届山东省ACM竞赛 A题 Nias and Tug-of-War
- Tug of War
- Tug of War
- poj2576 tug of war
- Tug of War
- ZCMU-Tug of War
- POJ 2576 Tug of War(模拟退火)
- ZOJ 1880 Tug of War
- ZOJ - 1880 Tug of War
- zoj 1880 - Tug of War
- UVA 10032 Tug of War
- UVa 10032 - Tug of War
- POJ 2576 Tug of War
- POJ 2576 Tug of War
- lightoj 1147 - Tug of War
- commons-httpclient 3.x如何按照host单独配置连接数和超时参数
- HDUOJ Max Sum Plus Plus Plus--1244
- 字符串转换md5
- C++学习笔记(四)C++ 概述
- 300. Longest Increasing Subsequence最长递增子序列
- sdut 3251 Nias and Tug-of-War 模拟
- 回溯法,DFS的应用
- swift 对字符串的一些处理
- 快速幂(C语言实现) 超详细 (转载)
- Linux常用命令大全[基础篇]
- StackView
- java之架构基础-动态代理&cglib
- poj & hdoj 1551 Cable master (二分+精度)
- c语言数组与指针的学习与思考