問題一覧 > 通常問題

No.2860 Heal Slimes

レベル : / AI推定難易度 : 1525 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 29
作問者 : dyktr_06 / テスター : square1001
お気に入りにしたユーザー ProblemId : 10859 / 自分の提出
問題文最終更新日: 2024-08-20 19:26:36
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
yukicoder contest 442 MMA Contest 019 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。