I. Absolute Game

Codeforces
IDCF10239I
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Alice and Bob are playing a game. Alice has an array $a$ of $n$ integers, Bob has an array $b$ of $n$ integers. In each turn, a player removes one element of his array. Players take turns alternately. Alice goes first. The game ends when both arrays contain exactly one element. Let $x$ be the last element in Alice's array and $y$ be the last element in Bob's array. Alice wants to maximize the absolute difference between $x$ and $y$ while Bob wants to minimize this value. Both players are playing optimally. Find what will be the final value of the game. The first line contains a single integer $n$ ($1 <= n <= 1 thin 000$) — the number of values in each array. The second line contains $n$ space-separated integers $a_1, a_2, \\dots, a_n$ ($1 <= a_i <= 10^9$) — the numbers in Alice's array. The third line contains $n$ space-separated integers $b_1, b_2, \\dots, b_n$ ($1 <= b_i <= 10^9$) — the numbers in Bob's array. Print the absolute difference between $x$ and $y$ if both players are playing optimally. In the first example, the $x = 14$ and $y = 10$. Therefore, the difference between these two values is $4$. In the second example, the size of the arrays is already $1$. Therefore, $x = 14$ and $y = 42$. ## Input The first line contains a single integer $n$ ($1 <= n <= 1 thin 000$) — the number of values in each array.The second line contains $n$ space-separated integers $a_1, a_2, \\dots, a_n$ ($1 <= a_i <= 10^9$) — the numbers in Alice's array.The third line contains $n$ space-separated integers $b_1, b_2, \\dots, b_n$ ($1 <= b_i <= 10^9$) — the numbers in Bob's array. ## Output Print the absolute difference between $x$ and $y$ if both players are playing optimally. [samples] ## Note In the first example, the $x = 14$ and $y = 10$. Therefore, the difference between these two values is $4$. In the second example, the size of the arrays is already $1$. Therefore, $x = 14$ and $y = 42$.
**Definitions** Let $ n \in \mathbb{Z} $ be the number of questions. Let $ s = s_1 s_2 \dots s_n $ be a string of length $ n $, where each $ s_i \in \{a, b, c, d, e\} $ represents Ayoub's answer to question $ i $. Let $ c \in \{a, b, c, d, e\} $ be the unknown correct answer letter for all questions (uniform across all questions). **Constraints** $ 1 \leq n \leq 1000 $ $ s_i \in \{a, b, c, d, e\} $ for all $ i \in \{1, \dots, n\} $ **Objective** For each possible $ c \in \{a, b, c, d, e\} $, define the number of correct answers as: $$ f(c) = \sum_{i=1}^{n} \mathbf{1}_{s_i = c} $$ Compute: - Minimum: $ \min_{c \in \{a,b,c,d,e\}} f(c) $ - Maximum: $ \max_{c \in \{a,b,c,d,e\}} f(c) $ Output: $ \left( \min_{c} f(c),\ \max_{c} f(c) \right) $
API Response (JSON)
{
  "problem": {
    "name": "I. Absolute Game",
    "description": {
      "content": "Alice and Bob are playing a game. Alice has an array $a$ of $n$ integers, Bob has an array $b$ of $n$ integers. In each turn, a player removes one element of his array. Players take turns alternately.",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10239I"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Alice and Bob are playing a game. Alice has an array $a$ of $n$ integers, Bob has an array $b$ of $n$ integers. In each turn, a player removes one element of his array. Players take turns alternately....",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of questions.  \nLet $ s = s_1 s_2 \\dots s_n $ be a string of length $ n $, where each $ s_i \\in \\{a, b, c, d, e\\} $ represents Ayoub's answer t...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments