Educational Round 27

A. Chess Tourney
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Berland annual chess tournament is coming!

Organizers have gathered 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 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 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?

 
Input

The first line contains one integer n (1 ≤ n ≤ 100).

The second line contains n integers a1, a2, ... a2n (1 ≤ ai ≤ 1000).

 
Output

If it's possible to divide all 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".

 
Examples
 
Input
2
1 3 2 4
Output
YES
 
Input
1
3 3
Output
NO

题意:把2n个人分成两队,每个数代表一个等级,等级高的胜等级低的,如果等级相等,怎不知道的谁胜谁负,
两队里的每个人都有可能比赛,所以要胜利的话,就要大于,
分析数据,在sort后,实际只要判断中间两项就好,这是由于从中间截成两队的原因

复制代码
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int a[205];
 4 int main(){
 5     int n;
 6     scanf("%d",&n);
 7     for(int i=1;i<=n+n;i++)
 8         scanf("%d",&a[i]);
 9     sort(a+1,a+1+(n<<1));
10     if(a[n]<a[n+1]) printf("YES\n");//a[5]<a[6]
11     else printf("NO\n");
12     return 0;
13 }
复制代码

 

posted @   浅忆~  阅读(136)  评论(0编辑  收藏  举报
编辑推荐:
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
阅读排行:
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(三):用.NET IoT库
· 【非技术】说说2024年我都干了些啥
点击右上角即可分享
微信分享提示