#abc288d. D - Range Add Query
D - Range Add Query
Score : points
问题描述
你将得到一个长度为 的整数序列 ,以及一个正整数 。
对于每个 ,判断 的连续子序列 是否是一个 好序列。
这里,长度为 的序列 被称为 好序列 当且仅当存在一种方法,通过执行以下操作一定次数(可能为零次)使得 中的所有元素都等于 。
选择一个整数 ,满足 ,并选择一个整数 (可能为负数)。将 加到 、、、 这 个元素上。
可以确保对于每个 ,都有 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given an integer sequence of length , , and a positive integer .
For each , determine whether a contiguous subsequence of , , is a good sequence.
Here, a sequence of length , , is good if and only if there is a way to perform the operation below some number of times (possibly zero) to make all elements of equal .
Choose an integer such that and an integer (possibly negative). Add to each of the elements .
It is guaranteed that for every .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. For each , the -th line should contain Yes
if the sequence is good, and No
otherwise.
Sample Input 1
7 3
3 -1 1 -2 2 0 5
2
1 6
2 7
Sample Output 1
Yes
No
The sequence $X \coloneqq (A_1, A_2, A_3, A_4, A_5, A_6) = (3, -1, 1, -2, 2, 0)$ is good. Indeed, you can do the following to make all elements equal .
- First, do the operation with , making .
- Next, do the operation with , making .
- Finally, do the operation with , making .
Thus, the first line should contain Yes
.
On the other hand, for the sequence $(A_2, A_3, A_4, A_5, A_6, A_7) = (-1, 1, -2, 2, 0, 5)$, there is no way to make all elements equal , so it is not a good sequence. Thus, the second line should contain No
.
Sample Input 2
20 4
-19 -66 -99 16 18 33 32 28 26 11 12 0 -16 4 21 21 37 17 55 -19
5
13 16
4 11
3 12
13 18
4 10
Sample Output 2
No
Yes
No
Yes
No
update @ 2024/3/10 12:02:13