F. Game With Array

Codeforces
IDCF10259F
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Petya and Vasya are competing with each other in a new interesting game as they always do. At the beginning of the game Petya has to come up with an array of $N$ positive integers. Sum of all elements in his array should be equal to $S$. Then Petya has to select an integer $K$ such that $0 <= K <= S$. In order to win, Vasya has to find a non-empty subarray in Petya's array such that the sum of all selected elements equals to either $K$ or $S -K$. Otherwise Vasya loses. You are given integers $N$ and $S$. You should determine if Petya can win, considering Vasya plays optimally. If Petya can win, help him to do that. The first line contains two integers $N$ and $S$ ($1 <= N <= S <= 10^6$) — the required length of the array and the required sum of its elements. If Petya can win, print "_YES_" (without quotes) in the first line. Then print Petya's array in the second line. The array should contain $N$ positive integers with sum equal to $S$. In the third line print $K$. If there are many correct answers, you can print any of them. If Petya can't win, print "_NO_" (without quotes). You can print each letter in any register (lowercase or uppercase). ## Input The first line contains two integers $N$ and $S$ ($1 <= N <= S <= 10^6$) — the required length of the array and the required sum of its elements. ## Output If Petya can win, print "_YES_" (without quotes) in the first line. Then print Petya's array in the second line. The array should contain $N$ positive integers with sum equal to $S$. In the third line print $K$. If there are many correct answers, you can print any of them.If Petya can't win, print "_NO_" (without quotes).You can print each letter in any register (lowercase or uppercase). [samples]
**Definitions** Let $ N, S \in \mathbb{Z} $ with $ 1 \leq N < S \leq 10^6 $. Let $ A = (a_1, a_2, \dots, a_N) $ be a sequence of positive integers such that $ \sum_{i=1}^N a_i = S $. Let $ K \in \mathbb{Z} $ satisfy $ 0 \leq K \leq S $. **Constraints** 1. $ a_i \geq 1 $ for all $ i \in \{1, \dots, N\} $. 2. $ \sum_{i=1}^N a_i = S $. 3. $ 0 \leq K \leq S $. **Objective** Determine whether there exists a sequence $ A $ and an integer $ K $ such that **no non-empty subarray** of $ A $ has sum equal to $ K $ or $ S - K $. If such $ A $ and $ K $ exist, output "YES", followed by $ A $ and $ K $; otherwise, output "NO".
API Response (JSON)
{
  "problem": {
    "name": "F. Game With Array",
    "description": {
      "content": "Petya and Vasya are competing with each other in a new interesting game as they always do. At the beginning of the game Petya has to come up with an array of $N$ positive integers. Sum of all element",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10259F"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Petya and Vasya are competing with each other in a new interesting game as they always do.\n\nAt the beginning of the game Petya has to come up with an array of $N$ positive integers. Sum of all element...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N, S \\in \\mathbb{Z} $ with $ 1 \\leq N < S \\leq 10^6 $.  \nLet $ A = (a_1, a_2, \\dots, a_N) $ be a sequence of positive integers such that $ \\sum_{i=1}^N a_i = S $.  \nLet $ K \\in...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments