No.2860 Heal Slimes
タグ : / 解いたユーザー数 29
作問者 :
Problem Statement
You are given $T$ test cases. Solve the following problem for each of them.
You keep $N$ slimes.
The slimes are lined up in a row, and the health of the $i$-th slime from the left is $H_i$.
You can cast the following healing magic any number of times.
- Choose any $K$ consecutive slimes and increase their health by $X$.
You do not like only some of the slimes having low health, so you want to make the health of all slimes the same.
Determine whether it is possible to make the health of all slimes the same.
Constraints
- $1 \leq T \leq 10^{5}$
- $2 \leq N \leq 2 \times 10^{5}$
- $1 \leq K \leq N$
- $1 \leq X \leq 10^{9}$
- $1 \leq H_i \leq 10^{9}$
- For the test cases contained in $1$ input, the sum of $N$ is at most $2 \times 10^{5}$.
- All input values are integers.
Input
The input is given from Standard Input in the following format.
$T$
$\text{case}_1$
$\vdots$
$\text{case}_T$
Each test case is given in the following format.
$N$ $K$ $X$
$H_1$ $H_2$ ... $H_{N}$
Output
Print $T$ lines. On the $i$-th line, for the $i$-th test case, print Yes if it is possible to make the health of all slimes the same, and No if it is impossible.
Sample
Sample 1
Input
4 4 2 3 5 2 5 8 8 3 4 17 5 5 21 29 17 21 25 4 3 8 2 3 5 7 3 2 1 7 7 7
Output
Yes Yes No Yes
For the $1$-st test case, you can make the health of all slimes the same by casting the healing magic as follows.
- Cast the healing magic on the $1, 2$-th slimes from the left. The health of the slimes becomes $(8, 5, 5, 8)$.
- Cast the healing magic on the $2, 3$-th slimes from the left. The health of the slimes becomes $(8, 8, 8, 8)$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。