~~~ Question surface ~~~
Question:
First, we need to observe a property, because at a fixed starting distance, after a fixed operation, the final position is fixed. We set the operation 1 ~ D [I].
If the witch can modify the I operation, it is equivalent to having gone through 1 ~ The I-1 operation, so Alice is already at the position of d [I-1, at this time, the witch can modify s [I] to reduce the distance between Alice and the end point, because if a s [I] can narrow the distance, Alice will definitely go, therefore, Alice's next position will be any position in [0, d [I-1.
Let's set f [I] to indicate the minimum starting distance X ~ N operations cannot reach the end.
Obviously, if f [I + 1] <= d [I-1], the witch will be able to make Alice unable to reach the end.
So consider how to transfer.
First, F [n + 1] indicates that no operation is performed, so the minimum distance is obviously 1.
Consider adding an operation s [I].
1. If the current operation is in F [I + 1] and S [I] is not executed, s [I] will not affect f [I, so the nearest distance is f [I + 1].
So when will s [I] not be executed? Obviously, s [I] needs to> = f [I + 1] and make s [I]-f [I + 1]> = f [I + 1], obtain f [I + 1] <= s [I]/2.
2. If this operation is executed, the distance between the operation and the destination will be shortened, because the operation passed through F [I + 1, the minimum distance to reach the destination is f [I + 1].
Alice in F [I + 1], after s [I], this operation shortens the distance from the destination, and the distance is already smaller than F [I + 1, therefore, it is possible to reach the destination at this time.
In order to make f [I] as small as possible, we must make f [I] arrive at f [I + 1] After s [I]. because f [I + 1] is operated by I + 1 ~ N is the smallest distance to reach the destination and cannot be smaller.
Therefore, F [I] = f [I + 1] + s [I].
1 # include <bits/stdc ++. h> 2 using namespace STD; 3 # define R register int 4 # Define AC 501000 5 # define ll long 6 7 int n, m; 8 int s [AC], d [AC], F [AC]; 9 10 inline int read () 11 {12 INT x = 0; char c = getchar (); 13 while (C> '9' | C <'0') C = getchar (); 14 While (C> = '0' & C <= '9 ') X = x * 10 + C-'0', c = getchar (); 15 return X; 16} 17 18 void pre () 19 {20 N = read (), d [0] = read (); 21 for (R I = 1; I <= N; I ++) 22 {23 s [I] = read (), d [I] = d [I-1]; 24 if (d [I]> = s [I]) d [I]-= s [I]; 25 else if (s [I]-d [I] <D [I]) d [I] = s [I]-d [I]; 26} 27} 28 29 void work () // F [I] indicates the operation I ~ N, making Alice unable to reach the minimum starting distance x30 {31 f [n + 1] = 1; 32 for (r I = N; I --) 33 If (F [I + 1] <= s [I]/2) f [I] = f [I + 1]; 34 else f [I] = f [I + 1] + s [I]; 35 m = read (); 36 for (R I = 1; I <= m; I ++) 37 {38 int x = read (); 39 if (d [X-1]> = f [x + 1]) printf ("Yes \ n"); 40 else printf ("NO \ n"); 41} 42} 43 44 int main () 45 {46 freopen ("in. in "," r ", stdin); 47 pre (); 48 work (); 49 fclose (stdin); 50 return 0; 51}
View code
Arc072e Alice in linear land