#P7427. Game Score Partitioning Problem

    ID: 20622 Type: Default 1000ms 256MiB

Game Score Partitioning Problem

Game Score Partitioning Problem

In this problem, two players, ljcc and his junior, play a game consisting of n rounds. In the i-th round, the winner receives i points. There is no possibility of a draw in any round.

Given the scores of ljcc and his junior, your task is to determine whether there exists a valid assignment of wins in each round such that the scores are achieved. Note that if ljcc's score is denoted by A and his junior's score is denoted by B, then together they must have accumulated a total of

\( S = \frac{n(n+1)}{2} \)

Since every integer between 0 and S can be represented as the sum of a subset of the set \( \{1, 2, \dots, n\} \), the condition for a valid scenario is:

[ A + B = S \quad \text{where} \quad S = \frac{n(n+1)}{2} ]

If this condition holds, then there exists a valid game outcome, otherwise not.

inputFormat

The input consists of a single line containing three space-separated integers:

  • n — the number of rounds,
  • A — ljcc's score, and
  • B — his junior's score.

It is guaranteed that all input values are non-negative integers.

outputFormat

Output a single line containing "YES" if there exists a valid assignment of wins in the rounds that results in the given scores, or "NO" otherwise.

sample

3 5 1
YES