Exercise
Limits: 2 sec., 512 MiB
This statement was translated automatically from Ukrainian.
Splinter has prepared an exercise for the Teenage Mutant Ninja Turtles. The turtles must complete \(n\) sets of this exercise. For each set, Splinter chooses a weight with which the turtles will perform the exercise in that set.
Splinter imposes the following conditions on the weights.
The weight in each set in kilograms must be an integer and range from \(0\) to \(m\) kilograms inclusive.
The sum of the weights in all \(n\) sets must be a multiple of \(p\).
The turtles have already completed \(k\) sets of the exercise.
Determine whether it is possible to choose the weights for the remaining sets to satisfy Splinter’s conditions.
Input
The first line contains four integers \(n\), \(k\), \(m\), and \(p\).
The second line contains \(k\) numbers \(a_i\) — the weights in the first \(k\) sets.
Output
In a single line, output Yes if it is possible to choose
the weights for the remaining sets, and No otherwise.
Constraints
\(1 \le k \le n \le 10^5\),
\(1 \le m, p \le 10^9\),
\(0 \le a_i \le m\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 4 3 10 11 4 7 4 | Yes |
| Input (stdin) | Output (stdout) |
|---|---|
| 7 4 7 47 4 4 4 4 | No |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|