#P6473. [NOI Online #2 入门组] 未了

[NOI Online #2 入门组] 未了

Problem Description

For offending the gods, Sisyphus is going to be punished.

Zeus orders Sisyphus to push a huge boulder up a slope of length LL. Sisyphus pushes upward at a constant speed of vv units per year (since the speed is constant, after 12\frac{1}{2} year he can push upward by v2\frac{v}{2} units). However, Zeus does not want Sisyphus to reach the top too quickly. Zeus can cast nn spells. If Zeus casts the ii-th spell (1in)(1\leq i \leq n), then when Sisyphus reaches position aia_i for the first time, he and the boulder will roll back to the bottom and start pushing again from the beginning. (The rolling time is ignored, i.e., it can be considered that right after reaching position aia_i for the first time, Sisyphus immediately restarts from the bottom.)

For example, Zeus casts two spells with ai=3a_i=3 and ai=5a_i=5. If Sisyphus’s speed is v=1v=1 and the slope length is L=6L=6, then the pushing process is as follows:

  • Spend 33 years to reach position 33.

  • Affected by the spell ai=3a_i=3, return to the bottom and start again.

  • Spend another 33 years to reach position 33, but since this is the second time reaching it, the spell ai=3a_i=3 no longer takes effect.

  • Spend 22 years to reach position 55.

  • Affected by the spell ai=5a_i=5, return to the bottom and start again.

  • Spend 66 years to go from the bottom to the top. The total time is 1414 years.

Now, Zeus has qq queries. For the ii-th query tit_i, Zeus wants to know the minimum number of spells he needs to cast so that the number of years Sisyphus spends to reach the top is greater than tit_i.

Input Format

The first line contains three integers n,L,vn,L,v, representing the number of spell types, the length of the slope, and Sisyphus’s speed.

The second line contains nn integers. The ii-th integer aia_i indicates the position where the ii-th spell takes effect. (1<i<n)(1<i<n)

The third line contains an integer qq, representing the number of Zeus’s queries.

The next qq lines each contain an integer. The integer on the ii-th line tit_i represents the ii-th query of Zeus. (1<i<n)(1<i<n)

Output Format

Output qq lines, each containing exactly one integer. The integer on the ii-th line is the answer to the ii-th query. (1iq)(1 \leq i\leq q)

If Zeus cannot make Sisyphus spend more than tit_i years no matter what, output 1-1.

3 6 3
3 5 1
4
1
3
4
5

0
1
2
-1

Hint

  1. Without using any spell, Sisyphus needs 22 years to reach the top.
  2. Using spell 22, Sisyphus needs 113\frac{11}{3} years to reach the top. (It takes 53\frac{5}{3} years to reach the position of spell 22 and roll down, then it takes 63=2\frac{6}{3}=2 years to reach the top.)
  3. Using spells 1,21,2, Sisyphus needs 143\frac{14}{3} years to reach the top.
  4. Zeus cannot make Sisyphus take more than 55 years to reach the top.

For test points 181\sim 8: n=1n=1.

For test points 9129\sim 12: n=2n=2.

For test points 131713\sim 17: n,q1000n,q\le 1000.

For all test points: 1n,q2×1051 \leq n,q \leq 2 \times 10^5, 1vL1091\leq v\leq L\leq 10^{9}, 1ai<L1\leq a_i < L, 1ti1091 \leq t_i\leq 10^9.

The testdata guarantees that all aia_i are pairwise distinct.

Translated by ChatGPT 5