codeforces 845A Chess Tourney

来源:互联网 发布:广州优享网络 编辑:程序博客网 时间:2024/05/16 12:00

点击打开链接

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 regardlessof 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
21 3 2 4
output
YES
input
13 3
output
NO

要是一队必须全胜,那就排序后直接判断第n个和n+1的值,是我想多了

#include<cstdio>#include<algorithm>using namespace std;int main(){    int n;    scanf("%d",&n);    int a[210];    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;}



原创粉丝点击