zoukankan      html  css  js  c++  java
  • CF-845A

    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
    2
    1 3 2 4
    output
    YES
    input
    1
    3 3
    output
    NO

    对2*n个数排序,比较n和n-1打大小,若n>n-1则YES。

    AC代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 
     4 int a[250];
     5 
     6 int main(){
     7     ios::sync_with_stdio(false);
     8     int n;
     9     cin>>n;
    10     for(int i=0;i<n*2;i++){
    11         cin>>a[i];
    12     }
    13     sort(a,a+2*n);
    14     if(a[n]==a[n-1]){
    15         cout<<"NO"<<endl;
    16     }
    17     else{
    18         cout<<"YES"<<endl;
    19     }
    20     return 0;
    21 } 
  • 相关阅读:
    Linux编译安装中configure、make和make install各自的作用
    转载的 Linux下chkconfig命令详解
    MYSQL主从不同步延迟原理分析及解决方案(摘自http://www.jb51.net/article/41545.htm)
    mysql主从延迟(摘自http://www.linuxidc.com/Linux/2012-02/53995.htm)
    http://ninghao.net/video/1554不错的学习网址
    javascript 内置对象和方法
    javascript 函数
    javascript 基础
    css z-index
    css 透明度
  • 原文地址:https://www.cnblogs.com/Kiven5197/p/7421888.html
Copyright © 2011-2022 走看看