A. Chess Tourney

Codeforces
IDCF845A
Time1000ms
Memory256MB
Difficulty
implementationsortings
English · Original
Chinese · Translation
Formal · Original
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 _r__i_. 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 **regardless** of the results of the drawing? ## Input The first line contains one integer _n_ (1 ≤ _n_ ≤ 100). The second line contains 2·_n_ integers _a_1, _a_2, ... _a_2_n_ (1 ≤ _a__i_ ≤ 1000). ## Output 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"_. [samples]
Berland 年度国际象棋锦标赛即将来临! 主办方已召集了 #cf_span[2·n] 名国际象棋选手,需要将他们分为两个队伍,每队 #cf_span[n] 人。第一队由 BerOil 赞助,第二队由 BerMobile 赞助。显然,主办方必须确保 BerOil 队获胜。 因此,主办方需要将所有 #cf_span[2·n] 名选手分为两个每队 #cf_span[n] 人的队伍,使得第一队在任何情况下都能获胜。 每位选手都有一个评分 #cf_span[ri]。已知评分更高的选手总是战胜评分更低的选手;若评分相等,则两人中的任意一方都可能获胜。 在队伍分配完成后,将进行抽签以形成 #cf_span[n] 对对手:每对由一名第一队选手和一名第二队选手组成。每位选手恰好出现在一对中,每对进行一场比赛。抽签是完全随机的。 是否可能将所有 #cf_span[2·n] 名选手分为两个每队 #cf_span[n] 人的队伍,使得无论抽签结果如何,每一对中第一队的选手都能获胜? 第一行包含一个整数 #cf_span[n](#cf_span[1 ≤ n ≤ 100])。 第二行包含 #cf_span[2·n] 个整数 #cf_span[a1, a2, ... a2n](#cf_span[1 ≤ ai ≤ 1000])。 如果可以将所有 #cf_span[2·n] 名选手分为两个每队 #cf_span[n] 人的队伍,使得无论抽签结果如何,每一对中第一队的选手都能获胜,则输出 _"YES"_;否则输出 _"NO"_。 ## Input 第一行包含一个整数 #cf_span[n](#cf_span[1 ≤ n ≤ 100])。第二行包含 #cf_span[2·n] 个整数 #cf_span[a1, a2, ... a2n](#cf_span[1 ≤ ai ≤ 1000])。 ## Output 如果可以将所有 #cf_span[2·n] 名选手分为两个每队 #cf_span[n] 人的队伍,使得无论抽签结果如何,每一对中第一队的选手都能获胜,则输出 _"YES"_;否则输出 _"NO"_。 [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $, $ 1 \leq n \leq 100 $. Let $ A = (a_1, a_2, \dots, a_{2n}) $ be a sequence of $ 2n $ integers, where $ 1 \leq a_i \leq 1000 $, representing the ratings of the players. **Constraints** - The players must be partitioned into two disjoint teams $ T_1 $ and $ T_2 $, each of size $ n $. - Team $ T_1 $ is the BerOil team (first team); team $ T_2 $ is the BerMobile team (second team). - For every possible bijection (drawing) pairing each player in $ T_1 $ with a unique player in $ T_2 $, every player in $ T_1 $ must have a rating strictly greater than their paired opponent in $ T_2 $. **Objective** Determine whether there exists a partition $ (T_1, T_2) $ such that: $$ \min(T_1) > \max(T_2) $$ where $ \min(T_1) $ is the smallest rating in team $ T_1 $, and $ \max(T_2) $ is the largest rating in team $ T_2 $. If such a partition exists, output "YES"; otherwise, output "NO".
Samples
Input #1
2
1 3 2 4
Output #1
YES
Input #2
1
3 3
Output #2
NO
API Response (JSON)
{
  "problem": {
    "name": "A. Chess Tourney",
    "description": {
      "content": "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",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF845A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Berland annual chess tournament is coming!\n\nOrganizers 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...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "Berland 年度国际象棋锦标赛即将来临!\n\n主办方已召集了 #cf_span[2·n] 名国际象棋选手,需要将他们分为两个队伍,每队 #cf_span[n] 人。第一队由 BerOil 赞助,第二队由 BerMobile 赞助。显然,主办方必须确保 BerOil 队获胜。\n\n因此,主办方需要将所有 #cf_span[2·n] 名选手分为两个每队 #cf_span[n] 人的队伍,使得第一队在任...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $, $ 1 \\leq n \\leq 100 $.  \nLet $ A = (a_1, a_2, \\dots, a_{2n}) $ be a sequence of $ 2n $ integers, where $ 1 \\leq a_i \\leq 1000 $, representing the ratings ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments