M. Value

Codeforces
IDCF10247M
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
_Pang_ believes that one cannot make an omelet without breaking eggs. For a subset $A$ of ${1, 2, \\dots, n}$, we calculate the score of $A$ as follows: The first line contains a single integer $n$ $(1 <= n <= 100000)$. The second line contains $n$ integers $a_1, a_2, \\dots, a_n$ $(1 <= a_i <= 1000000000)$. The third line contains $n$ integers $b_1, b_2, \\dots, b_n$ $(1 <= b_i <= 1000000000)$. Print a single integer $x$ — the maximum possible score. ## Input The first line contains a single integer $n$ $(1 <= n <= 100000)$.The second line contains $n$ integers $a_1, a_2, \\dots, a_n$ $(1 <= a_i <= 1000000000)$.The third line contains $n$ integers $b_1, b_2, \\dots, b_n$ $(1 <= b_i <= 1000000000)$. ## Output Print a single integer $x$ — the maximum possible score. [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ with $ 1 \leq n \leq 100000 $. Let $ A = \{1, 2, \dots, n\} $. Let $ \mathbf{a} = (a_1, a_2, \dots, a_n) \in \mathbb{Z}^n $ with $ 1 \leq a_i \leq 10^9 $. Let $ \mathbf{b} = (b_1, b_2, \dots, b_n) \in \mathbb{Z}^n $ with $ 1 \leq b_i \leq 10^9 $. For a subset $ S \subseteq A $, define the score as: $$ \text{score}(S) = \sum_{i \in S} a_i - \sum_{i \notin S} b_i $$ **Objective** Maximize $ \text{score}(S) $ over all subsets $ S \subseteq A $.
API Response (JSON)
{
  "problem": {
    "name": "M. Value",
    "description": {
      "content": "_Pang_ believes that one cannot make an omelet without breaking eggs. For a subset $A$ of ${1, 2, \\\\dots, n}$, we calculate the score of $A$ as follows:  The first line contains a single integer $n$",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10247M"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "_Pang_ believes that one cannot make an omelet without breaking eggs.\n\nFor a subset $A$ of ${1, 2, \\\\dots, n}$, we calculate the score of $A$ as follows: \n\nThe first line contains a single integer $n$...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ with $ 1 \\leq n \\leq 100000 $.  \nLet $ A = \\{1, 2, \\dots, n\\} $.  \nLet $ \\mathbf{a} = (a_1, a_2, \\dots, a_n) \\in \\mathbb{Z}^n $ with $ 1 \\leq a_i \\leq 10^9...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments