atcoder#ARC072C. [ARC072E] Alice in linear land

[ARC072E] Alice in linear land

Score : 900900 points

Problem Statement

Alice lives on a line. Today, she will travel to some place in a mysterious vehicle. Initially, the distance between Alice and her destination is DD. When she input a number xx to the vehicle, it will travel in the direction of the destination by a distance of xx if this move would shorten the distance between the vehicle and the destination, and it will stay at its position otherwise. Note that the vehicle may go past the destination when the distance between the vehicle and the destination is less than xx.

Alice made a list of NN numbers. The ii-th number in this list is did_i. She will insert these numbers to the vehicle one by one.

However, a mischievous witch appeared. She is thinking of rewriting one number in the list so that Alice will not reach the destination after NN moves.

She has QQ plans to do this, as follows:

  • Rewrite only the qiq_i-th number in the list with some integer so that Alice will not reach the destination.

Write a program to determine whether each plan is feasible.

Constraints

  • 1N51051 \leq N \leq 5*10^5
  • 1Q51051 \leq Q \leq 5*10^5
  • 1D1091 \leq D \leq 10^9
  • 1di109(1iN)1 \leq d_i \leq 10^9(1 \leq i \leq N)
  • 1qiN(1iQ)1 \leq q_i \leq N(1 \leq i \leq Q)
  • D and each did_i are integers.

Input

Input is given from Standard Input in the following format:

NN DD

d1d_1 d2d_2 ...... dNd_N

QQ

q1q_1 q2q_2 ...... qQq_Q

Output

Print QQ lines. The ii-th line should contain YES if the ii-th plan is feasible, and NO otherwise.

4 10
3 4 3 3
2
4 3
NO
YES

For the first plan, Alice will already arrive at the destination by the first three moves, and therefore the answer is NO. For the second plan, rewriting the third number in the list with 55 will prevent Alice from reaching the destination as shown in the following figure, and thus the answer is YES.

5 9
4 4 2 3 2
5
1 4 2 3 5
YES
YES
YES
YES
YES

Alice will not reach the destination as it is, and therefore all the plans are feasible.

6 15
4 3 5 4 2 1
6
1 2 3 4 5 6
NO
NO
YES
NO
NO
YES