标签:等于 clear example beginning bit src inf other tty
Berland annual chess tournament is coming!
Organizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers should guarantee the win for the team of BerOil.
Thus, organizers should divide all 2·n players into two teams with n people each in such a way that the first team always wins.
Every chess player has its rating ri. It is known that chess player with the greater rating always wins the player with the lower rating. If their ratings are equal then any of the players can win.
After teams assignment there will come a drawing to form n pairs of opponents: in each pair there is a player from the first team and a player from the second team. Every chess player should be in exactly one pair. Every pair plays once. The drawing is totally random.
Is it possible to divide all 2·n players into two teams with n people each so that the player from the first team in every pair wins regardlessof the results of the drawing?
The first line contains one integer n (1?≤?n?≤?100).
The second line contains 2·n integers a1,?a2,?... a2n (1?≤?ai?≤?1000).
If it‘s possible to divide all 2·n players into two teams with n people each so that the player from the first team in every pair wins regardless of the results of the drawing, then print "YES". Otherwise print "NO".
题意:给2*n个选手拥有不用的实力,实力高的肯定能赢实力低的,相同实力随机赢,问能否把他们分成两组使一组无论怎么匹配打都能赢?
题解:sort()一下,然判断那组是否最小值比另外一组最小值大
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define ll long long using namespace std; const int maxn=2e2+5; const ll inf=0x4f4f4f4f4f; int n,k; int a[maxn]; int main() { scanf("%d",&n); for(int i=0;i<2*n;i++) { scanf("%d",&a[i]); } sort(a,a+2*n); if(a[n]>a[n-1])printf("YES\n"); else printf("NO\n"); }
http://codeforces.com/contest/845
标签:等于 clear example beginning bit src inf other tty
原文地址:http://www.cnblogs.com/lhclqslove/p/7413390.html