A. Chess Tourney【Educational Codeforces 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


题目大意, 给你 2×n 个队员, 团队任务:    如果分成两队  那么一队肯定可以赢二队。

分完一二队后还是分成两队,两队各抽一人 , ri大的会赢得比赛         问能否让每个人都赢一遍 。



所以一开始要把所有弱的放到一队中,那么一半的队员就已赢得一次比赛。再比时不用再分了,只有原来一队中最大的 比 原来二队中最小的还小。

那么才能无论怎么匹配比赛 二队的每个人都能赢一次。

。。。比赛时理解错题意了。。。。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int a[1234];
    int sum=0;
    for(int i=1; i<=2*n; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+2*n+1);
    if(a[n] != a[n+1])
        printf("YES\n");
    else printf("NO\n");
    return 0;
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值