atcoder#ABC288D. [ABC288D] Range Add Query
[ABC288D] Range Add Query
Score : points
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.
7 3
3 -1 1 -2 2 0 5
2
1 6
2 7
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
.
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
No
Yes
No
Yes
No