No.1940 Escape through + -
タグ : / 解いたユーザー数 106
作問者 :
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.
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もしくは右上の雲マークをクリックしてアカウントを作成してください。