AtCoder Regular Contest 215
A
僵尸
Zombie
AtCoder
⌀ 1106
原题
←B →

僵尸AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

There is a road of length $L$ extending left and right. There are $N$ zombies on this road, and the $i$-th zombie is at a distance of $A_i$ from the left end of the road. Here, $L$ and all $A_i$ are even.

有一条长度为 $L$ 的道路,向左右延伸。道路上有 $N$ 只僵尸,第 $i$ 只僵尸距离道路左端 $A_i$。其中,$L$ 和所有 $A_i$ 都是偶数。AI (CI翻译)

You have $K$ pieces of bait for the zombies, and you can place a piece of bait at any position on the road, including both ends, at any time. However, there must never be a moment when two or more pieces of bait exist on the road simultaneously. When bait exists on the road, each zombie moves toward the bait at a speed of $1$ per unit time. When one or more zombies reach the same position as the bait, the bait is eaten and disappears instantly.

你有 $K$ 份僵尸诱饵,可以在任意时刻将一份诱饵放在道路上的任意位置,包括道路两端。但任何时刻,道路上都不能同时存在两份或更多诱饵。当道路上存在诱饵时,每只僵尸都会以单位时间移动 $1$ 的速度朝诱饵移动。当一只或多只僵尸到达诱饵所在的位置时,诱饵会被吃掉并立即消失。AI (CI翻译)

When no bait exists on the road, zombies do not move. Find the maximum total amount of time bait exists on the road when the times and positions to place the bait are chosen optimally. It can be proved that the answer is an integer.

当道路上没有诱饵时,僵尸不会移动。请在最优选择放置诱饵的时刻和位置的情况下,求诱饵在道路上存在的总时间最大值。可以证明答案是整数。AI (CI翻译)

You are given $T$ test cases; solve each one.

给定 $T$ 组测试数据,请分别求解。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1 \le T \le 10^5$
  • $1 \le N \le 2 \times 10^5$
  • $1 \le K \le 10^9$
  • $2 \le L \le 10^9$
  • $0 \le A_i \le L$
  • $L$ is even.
  • All $A_i$ are even.
  • The sum of $N$ over all test cases is at most $2 \times 10^5$.
  • All input values are integers.
  • $1 \le T \le 10^5$
  • $1 \le N \le 2 \times 10^5$
  • $1 \le K \le 10^9$
  • $2 \le L \le 10^9$
  • $0 \le A_i \le L$
  • $L$ 为偶数。
  • 所有 $A_i$ 均为偶数。
  • 所有测试数据中 $N$ 的总和不超过 $2 \times 10^5$。
  • 所有输入值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入从标准输入读入,格式如下:AI (CI翻译)

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
AI (CI翻译)

Each test case is given in the following format:

每组测试数据的格式如下:AI (CI翻译)

N K L
A_1 A_2 \ldots A_N

N K L
A_1 A_2 \ldots A_N
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output $T$ lines.

输出 $T$ 行。AI (CI翻译)

The $i$-th line should contain the maximum total amount of time bait exists on the road for the $i$-th test case.

第 $i$ 行应包含第 $i$ 组测试数据中,诱饵在道路上存在的总时间最大值。AI (CI翻译)

样例

Input #1
3
2 2 20
4 18
8 9 14
0 2 4 6 8 10 12 14
3 3 140
120 70 20
Output #1
18
40
160
For the first test case, it is optimal to place the bait as follows. - First, place bait at position $11$. The two zombies simultaneously reach position $11$ after $7$ units of time and eat the bait. - Then, place bait at position $0$. The two zombies simultaneously reach position $0$ after $11$ units of time and eat the bait. The total amount of time bait exists on the road is $7 + 11 = 18$.
题目信息
题号
arc215_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。