CF2055D Scarecrow
题目描述
### 题意翻译
在一个数轴上,原点处有一只乌鸦。同时在这个数轴上还有 $n$ 个稻草人,分别位于 $a_1,a_2,\cdots,a_n$ 的位置。这些稻草人可以进行移动,每 $1$ 秒可以向左或者向右一个单位长度。**稻草人开始移动、静止不动或者改变移动方向的时间可以是任意时刻,可以不是整数**。
由于乌鸦很害怕稻草人,所以乌鸦想要距离它前边且离它最近的稻草人至少有 $k$ 的长度。为了能够保证这 $k$ 的长度,乌鸦会施展它的传送能力:
- 令 $x$ 为乌鸦当前的位置,$y$ 为最大的的稻草人位置且满足 $y\le x$,如果 $x-y
输入格式
第一行一个整数 $t$,代表数据组数。
对于每组测试数据,第一行三个整数 $n,k,l$,代表稻草人个数、乌鸦与它前边的稻草人的最小距离以及乌鸦要到达的地点 $l$。
接下来一行 $n$ 个整数,表示每个稻草人的位置,满足 $0\le a_1\le a_2\le \cdots\le a_n\le l$。
输出格式
对于每一组测试数据,输出一行一个整数,表示乌鸦位置大于等于 $l$ 所需要的最短时间的两倍。
### 样例解释
在第一组数据中,由于 $0$ 处的稻草人,乌鸦会在一开始直接瞬移到位置 $3$。在接下来的两秒中,稻草人向右移动两个单位,乌鸦将会瞬移到位置 $5$,花费 $2$ 秒,故输出 $4$。
在第二组数据中,前两秒,第一个稻草人和第二个稻草人会从位置 $3$ 和 $5$ 移动到位置 $0$ 和 $3$,第三个稻草人不动。这时,由于 $0$ 处的稻草人,乌鸦会瞬移到位置 $2$。在接下来的 $0.5$ 秒内,第一个稻草人向右移动 $0.5$,第二个和第三个稻草人都向左移动 $0.5$ 个单位长度,这时三个稻草人的位置分别为 $0.5,2.5,4.5$,导致乌鸦会瞬移到位置 $6.5$,所以乌鸦飞行到目标位置用了 $2.5$ 秒,故输出为 $5$。
说明/提示
In the first test case, the crow instantly teleports to position $ 3 $ due to the scarecrow at position $ 0 $ . This scarecrow may then move to position $ 2 $ , causing the crow to continuously move from position $ 3 $ to position $ 5 $ , completing the trip in $ 2 $ seconds. Therefore, the output is $ 4 $ .
In the second test case, scarecrow $ 1 $ and scarecrow $ 2 $ can move to positions $ 0 $ and $ 3 $ , respectively, in $ 2 $ seconds, while scarecrow $ 3 $ remains at position $ 5 $ . The crow teleports to position $ 2 $ due to scarecrow $ 1 $ . Then, scarecrow $ 1 $ moves to the right while scarecrow $ 2 $ and scarecrow $ 3 $ move to the left for $ 0.5 $ seconds. This causes the crow to continuously move from position $ 2 $ to position $ 2.5 $ due to scarecrow $ 1 $ moving right from position $ 0 $ . After this half second, the scarecrows will be at positions $ 0.5, 2.5, 4.5 $ . Scarecrow $ 2 $ , now at position $ 2.5 $ , causes the crow to instantly teleport to position $ 4.5 $ , and scarecrow $ 3 $ at position $ 4.5 $ causes it to instantly teleport to position $ 6.5 $ , which exceeds $ \ell = 5 $ . Therefore, the crow finishes the trip in just $ 2.5 $ seconds, and the output is $ 5 $ .
It can be shown that these are the minimum possible times for both test cases.