Codeforces Round 1085 (Div. 1 + Div. 2)
B
One Night At Freddy's
Codeforces
1600
原题
← AC →
翻译中…

Let $n, m, \ell$ be positive integers. You have made the unfortunate decision to work as a night guard at Freddy Fazbear's Pizzeria, where there are $m$ animatronics numbered $1, \ldots, m$ waiting to jumpscare you.

翻译中…

The night consists of $\ell$ seconds, numbered $1, \ldots, \ell$. The $j$-th of the $m$ animatronics has a danger level $d_j$, and initially $d_1 = \ldots = d_m = 0$. Every second, the danger level of exactly one animatronic will increase by $1$, and throughout the night, you are able to observe all values of $d_j$ at the current time. For example, if $m = 2$, one possible list of danger levels after $5$ seconds is $[d_1, d_2] = [2, 3]$.

翻译中…

You are not defenseless, however. At each of the $n$ fixed times $a_i$ ($1 \leq a_1 \lt \ldots \lt a_n \leq \ell$), you can shine your flashlight on exactly one animatronic $j_i$ of your choice. This occurs immediately after the $a_i$-th second and sets its danger level back to zero, i.e. $d_{j_i} := 0$. Note that this choice is made independently for each flashlight use $a_i$. Continuing the example from before, if $a_1 = 5$ and you choose to flash the second animatronic at that time, the danger levels after $5$ seconds will be $[d_1, d_2] = [2, 0]$.

翻译中…

Let the overall danger be the maximum danger across all animatronics, i.e. $\max_{1 \leq j \leq m} d_j$. You will lose if the overall danger at the end of the night (after $\ell$ seconds) is greater than $x$. Find the minimum value of $x$ such that regardless of the actions of the animatronics, you can guarantee that overall danger will be less than or equal $x$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains three integers $n$, $m$, and $\ell$ ($1 \leq n, m, \ell \leq 2 \cdot 10^5, n \leq \ell, 1 \leq m \cdot \ell \leq 2 \cdot 10^5$) — the number of flashlight actions, animatronics, and the length of the night, respectively.

翻译中…

The next line contains $n$ integers $a_i$ ($1 \leq a_1 \lt \ldots \lt a_n \leq \ell$) — the times at which you get to shine your flashlight.

翻译中…

It is guaranteed that the sum of $m \cdot \ell$ over all test cases does not exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output a single integer — the minimum $x$ such that you can guarantee that your final danger level is at most $x$.

翻译中…

Note

翻译中…

In the first test case, there are $2$ animatronics and a night length of $10$, and you get to flash after the $10$-th second. We will show that $x = 5$ is always possible. After $10$ seconds, notice that one animatronic must have at least $5$ danger, and the other must have at most $5$ danger. So, we can flash the higher one and get a final danger level at most $5$. It can be shown that $5$ is the minimum possible value of $x$.

翻译中…

In the second test case, there is only one animatronic and a night length of $32$. Notice that in this case, the animatronic just increments its danger by $1$ each second. So, after the $25$-th second, we reset its danger to $0$. Seven more seconds pass before the night ends, so the final danger we get is always $7$.

翻译中…

In the third test case, it can be proven that the minimum possible value of $x$ is $19$.

翻译中…

样例

Input #1
7
1 2 10
10
5 1 32
1 4 9 16 25
2 3 40
13 37
2 2 7
6 7
8 5 60
3 17 20 28 36 44 45 50
6 7 1987
6 7 66 77 666 777
1 1 1
1
Output #1
5
7
19
1
19
1477
0
InputCopy OutputCopy
题目信息
题号
2207B
时间限制
1 s
内存限制
256 MB
标签
博弈论
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。