luogu#P7894. 『JROI-3』1÷0

    ID: 7186 远端评测题 600~1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>模拟单调队列2021O2优化洛谷月赛

『JROI-3』1÷0

Background

1÷0=梦恋
   On a distant hill, you can see a scene as if the heavens and the earth are collapsing.

    "——A report has come from the 'Design Entity'——Design successfully reproduced at power '72.8%'——Begin synchronization."

    One female body of the Ex-Machina said this to Riku, then raised her hand.

    "【Tenka】——Org.0000——'True Canon · Star-Slayer'——Please."

    ——What appeared in the void was something that looked like a small tower, a spear stuck into the ground.

    What was just witnessed was a violent vortex that seemed to end the world.

Problem Description

Sora uses checkers to simulate the movement of the Ex-Machina in the "Holy War".

On an infinite number line, there are nn immovable checkers. Sora will ask: if you place one movable checker at a position, how many jumps can it make at most. Sora will ask many times, and each query is independent.

Let the coordinate of the ii-th immovable checker be xi(i[1,n])x_i\left(\forall i\in\left[1,n\right]\right).

The movement rules are as follows:

  • This checker must be movable.
  • If the checker is at aa and the target position is bb, then there must be exactly one checker between the two positions, and the distance from the middle checker to aa and bb must be equal.

Formally, it should satisfy:

$$\sum_{k=1}^n \left[x_k\in\left[b,a\right]\right]=1$$

and k xk=a+b2\exists k\ x_k=\dfrac{a+b}{2}.

  • The problem setter is too kind (so you can only jump to the left).

Input Format

The first line contains two integers n,qn,q, as described.

The next line contains nn integers; the ii-th one is xix_i.

The next line contains qq numbers x0x_0, meaning the position where the movable checker is placed.

Output Format

Output qq lines. Each line contains an integer. The ii-th line is the answer to the ii-th query.

3 3
3 5 8
4 6 7
1
2
0

Hint

Sample Explanation 1

$$\Huge\Box\Box\blacksquare{\color{red}{\Box}}\blacksquare{\color{red}{\Box}}{\color{red}{\Box}}\blacksquare\Box\Box$$

The three red squares from left to right are the query positions.

  • For the first query, it can jump 11 step, from 4 to 2.
  • For the second query, it can jump 22 steps, from 6 to 4 to 2.
  • For the third query, the checker cannot move left, because there is an immovable checker at the position with the same distance on the left.

For 100%100\% of the testdata, 1n3×1061\le n\leq 3\times 10^6, 1q3×1051\le q\leq3\times 10^5, 1x10181\le x\le 10^{18}, xi+1<xi+1(i[1,n1])x_i+1\lt x_{i+1}(\forall i \in [1,n-1]).

Subtask ID nn\le qq\le Time Limit Memory Limit Special Limit
Subtask 0 (10 pts) 10310^3 1000 ms1000\ \rm\small ms 512.00 MB\rm512.00\small\ MB
Subtask 1 (30 pts) A\rm A
Subtask 2 (25 pts) B\rm B
Subtask 3 (25 pts) 3×1053 \times 10^5 600 ms600\ \rm\small ms
Subtask 4 (10 pts)
  • Constraint A\text{A}: xn2×105x_n\le2\times 10^5.
  • Constraint B\text{B}: There are no more than 5050 indices ii that do not satisfy xixi1100x_i-x_{i-1}\le 100. For the remaining ii, it satisfies ixixi12×105\sum_{i}{x_i-x_{i-1}} \le 2\times 10^5.

Translated by ChatGPT 5