#P11110. [ROI 2023] 陶陶装苹果 (Day 2)
[ROI 2023] 陶陶装苹果 (Day 2)
Background
Translated from ROI 2023 D2T3。
Tao Tao has apples with integer weights . They are placed on a table, and there are also two baskets with large enough capacity.
Tao Tao chooses an integer . For each apple with weight , he may put it into one of the baskets, or leave it on the table. Apples with weight greater than will always remain on the table.
If Tao Tao can place the apples of weight at most into the baskets so that the total weight of apples in the first basket equals , and the total weight of apples in the second basket equals , then is called a reachable pair for . If for all and satisfying and , is a reachable pair for , then is called perfect.
Problem Description
Tao Tao will ask you times. For each triple , determine whether is perfect.
Input Format
The first line contains two integers and , representing the number of apples Tao Tao has and the number of queries to process ().
The second line contains integers , representing the weights of the apples ().
The third line contains an integer , which will be used in the following input ().
The next lines describe the queries. Queries are numbered from to . Each line contains three integers (), meaning that in this query $k = j - v \times z,a = c - v \times z,b = d - v \times z$, where is the sum of the indices of the previous queries whose answers were Yes. It is guaranteed that .
In this problem, for most testdata, equals . In this case, the values of are , respectively.
Output Format
For each query, if the pair is perfect in that query, output Yes; otherwise output No.
8 5
17 1 3 2 100 5 6 1
0
6 15 3
9 4 4
5 15 3
17 34 1
16 33 2
Yes
No
No
Yes
No
8 5
17 1 3 2 100 5 6 1
1
6 15 3
10 5 5
6 16 4
18 35 2
21 38 7
Yes
No
No
Yes
No
Hint

Translated by ChatGPT 5