問題一覧 > 通常問題

No.1940 Escape through + -

レベル : / AI推定難易度 : 189 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 106
作問者 : matcharate12 / テスター : Namu3
お気に入りにしたユーザー ProblemId : 7708 / 自分の提出
問題文最終更新日: 2022-05-18 20:29:17
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original

Problem Statement

matcharate12 is trapped in a small room somewhere.
The key to getting out of the room is a sequence $A$ of length $N$. It seems that he can escape by making the sum of the elements of the sequence equal to $S$.
In fact, matcharate12 is a wizard and can change the elements of the sequence.
Specifically, the effect of his magic is as follows.

  • Choose an integer $i$ between $1$ and $N$, inclusive, and change the $i$-th element $A_i$ of the sequence to $A_i+M$ or $A_i-M$.

  • This magic can be used any number of times. Furthermore, he can cast the magic as many times as he likes on $1$ element.
    Also, $M$ has already been fixed by matcharate12.

    Using the same magic over and over is hard work, so if he cannot escape that way, his effort is wasted.
    For the given sequence, determine whether matcharate12 can escape from the room.

    Input

    $N\ M\ S$
    $A_1\ A_2\ \dots \ A_N$
    

    ・$1\le N\le 10^5$
    ・$1\le M\le 10^{18}$
    ・$1\le S\le 10^{18}$
    ・$1\le A_i\le 10^9$
    ・All inputs are integers.

    Output

    Print Yes if he can escape, and No otherwise.

    Sample

    Sample 1
    Input
    4 2 10
    1 1 1 1
    
    Output
    Yes

    For example, if he casts the magic that changes an element to $A_i+M$ on each of $A_1,A_2,A_3$ exactly $1$ time, the sequence after the magic becomes $A=(1+2,1+2,1+2,1)=(3,3,3,1)$. Its sum is equal to $10$, so matcharate12 can escape. Therefore, print Yes.

    Sample 2
    Input
    2 2 5
    1 3
    
    Output
    No

    No matter how he casts the magic, the sum cannot be made equal to $5$.

    Sample 3
    Input
    3 1 1000000007
    1 2 5
    
    Output
    Yes

    The number of times the magic is used may exceed $10^9$.

    Sample 4
    Input
    10 1414 1814
    14 14 21 35 62 37 30 95 4 88
    
    Output
    Yes

    Although not shown in the sample inputs, note that elements of the sequence after using the magic may exceed $10^{18}$.

    提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。