CF2207B.One Night At Freddy's

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Five Nights at Freddy's 1 Song — The Living Tombstone

Let n,m,ℓ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 mm animatronics numbered 1,…,m1, \ldots, m waiting to jumpscare you.

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

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

Let the overall danger be the maximum danger across all animatronics, i.e. max⁡1≤j≤mdj\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 xx. Find the minimum value of xx such that regardless of the actions of the animatronics, you can guarantee that overall danger will be less than or equal xx.

《玩具熊的五夜后宫》主题曲 — The Living Tombstone

设 n,m,ℓn, m, \ell 为正整数。你不幸地决定在弗雷迪·法兹巴尔的披萨店担任夜间保安,店内共有 mm 个编号为 1,…,m1, \ldots, m 的机械玩偶,随时准备对你发起惊吓袭击。

一整晚共持续 ℓ\ell 秒,秒数依次编号为 1,…,ℓ1, \ldots, \ell。第 jj 个(共 mm 个)机械玩偶具有危险等级 djd_j;初始时所有危险等级均为零,即 d1=…=dm=0d_1 = \ldots = d_m = 0。每一秒,恰好一个机械玩偶的危险等级增加 11;在整个夜晚中,你始终能实时观测到所有 djd_j 的当前值。例如,若 m=2m = 2,经过 55 秒后,一种可能的危险等级序列为 [d1,d2]=[2,3][d_1, d_2] = [2, 3]。

然而,你并非毫无防备。在固定的 nn 个时刻 aia_i(满足 1≤a1<…<an≤ℓ1 \leq a_1 \lt \ldots \lt a_n \leq \ell),你可以使用手电筒照射恰好一个你选定的机械玩偶 jij_i。该操作发生在第 aia_i 秒结束之后立即执行,并将其危险等级重置为零,即令 dji:=0d_{j_i} := 0。注意:每次手电筒使用(即每个 aia_i)所选择的玩偶 jij_i 是独立决定的。延续前面的例子,若 a1=5a_1 = 5,且你在该时刻选择照射第二个玩偶,则经过 55 秒后的危险等级变为 [d1,d2]=[2,0][d_1, d_2] = [2, 0]。

定义总体危险度为所有玩偶危险等级的最大值,即 max⁡1≤j≤mdj\max_{1 \leq j \leq m} d_j。若在夜晚结束时(即 ℓ\ell 秒后)总体危险度大于 xx,你将失败。求最小的 xx 值,使得无论机械玩偶如何增加危险等级(即无论每秒哪个玩偶被选中增加危险等级),你总能通过合理选择每次手电筒照射的目标玩偶,保证最终总体危险度不超过 xx。

输入格式

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

The first line of each test case contains three integers nn, mm, and ℓ\ell (1≤n,m,ℓ≤2⋅105,n≤ℓ,1≤m⋅ℓ≤2⋅1051 \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 nn integers aia_i (1≤a1<…<an≤ℓ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⋅ℓm \cdot \ell over all test cases does not exceed 2⋅1052 \cdot 10^5.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例的第一行包含三个整数 nn、mm 和 ℓ\ell(1≤n,m,ℓ≤2⋅1051 \leq n, m, \ell \leq 2 \cdot 10^5,n≤ℓn \leq \ell,1≤m⋅ℓ≤2⋅1051 \leq m \cdot \ell \leq 2 \cdot 10^5),分别表示手电筒操作次数、机械玩偶数量以及夜晚总时长。

下一行包含 nn 个整数 aia_i(1≤a1<…<an≤ℓ1 \leq a_1 \lt \ldots \lt a_n \leq \ell),表示你可开启手电筒的时间点。

保证所有测试用例中 m⋅ℓm \cdot \ell 的总和不超过 2⋅1052 \cdot 10^5。

输出格式

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

对于每个测试用例,输出一个整数 —— 使得你能够保证最终危险等级不超过该值的最小 xx。

输入输出样例

  • 输入#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

    输出#1

    5
    7
    19
    1
    19
    1477
    0

说明/提示

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

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

In the third test case, it can be proven that the minimum possible value of xx is 1919.

在第一个测试用例中,有 22 个机械玩偶,夜晚持续时间为 1010 秒,你可在第 1010 秒后进行一次闪光。我们将证明 x=5x = 5 总是可行的。经过 1010 秒后,注意到其中一个机械玩偶的危险值至少为 55,而另一个至多为 55。因此,我们可以对危险值较高的那个机械玩偶执行闪光操作,从而使得最终危险值至多为 55。可以证明,55 是 xx 的最小可能取值。

在第二个测试用例中,仅有一个机械玩偶,夜晚持续时间为 3232 秒。注意在此情况下,该机械玩偶每秒将其危险值增加 11。因此,在第 2525 秒后,我们将其危险值重置为 00。此后夜晚还剩余 77 秒,故最终得到的危险值恒为 77。

在第三个测试用例中,可以证明 xx 的最小可能取值为 1919。

输入解题思路,AI测评打分。不知道怎么写?

首页