XXYYX

AtCoder
IDarc157_a
Time2000ms
Memory256MB
Difficulty
Determine whether there is a string $S$ of length $N$ consisting of `X` and `Y` that satisfies the following condition. **Condition:** Among the $(N - 1)$ pairs of consecutive characters in $S$, * exactly $A$ are `XX`, * exactly $B$ are `XY`, * exactly $C$ are `YX`, and * exactly $D$ are `YY`. ## Constraints * $1 \leq N \leq 2 \times 10^5$ * $A \geq 0$ * $B \geq 0$ * $C \geq 0$ * $D \geq 0$ * $A + B + C + D = N - 1$ ## Input The input is given from Standard Input in the following format: $N$ $A$ $B$ $C$ $D$ [samples]
Samples
Input #1
5 1 1 1 1
Output #1
Yes

For instance, if $S = {}$`XXYYX`, the pairs of consecutive characters are `XX`, `XY`, `YY`, and `YX` from left to right. Each pattern occurs exactly once, so the condition is satisfied.
Input #2
5 1 2 1 0
Output #2
Yes

For instance, $S = {}$`XXYXY` satisfies the condition.
Input #3
5 0 4 0 0
Output #3
No

No string satisfies the condition.
API Response (JSON)
{
  "problem": {
    "name": "XXYYX",
    "description": {
      "content": "Determine whether there is a string $S$ of length $N$ consisting of `X` and `Y` that satisfies the following condition. **Condition:** Among the $(N - 1)$ pairs of consecutive characters in $S$, *   ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc157_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Determine whether there is a string $S$ of length $N$ consisting of `X` and `Y` that satisfies the following condition.\n**Condition:** Among the $(N - 1)$ pairs of consecutive characters in $S$,\n\n*   ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments