CF1329E.Dreamoon Loves AA

NOI/NOI+/CTSC

通过率:0%

时间限制:3.50s

内存限制:256MB

AC君温馨提醒

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

题目描述

There is a string of length n+1n+1 of characters 'A' and 'B'. The first character and last character of the string are equal to 'A'.

You are given mm indices p1,p2,…,pmp_1, p_2, \ldots, p_m (00-indexation) denoting the other indices of characters 'A' in the string.

Let's denote the minimum distance between two neighboring 'A' as ll, and maximum distance between neighboring 'A' as rr.

For example, (l,r)(l,r) of string "ABBAABBBA" is (1,4)(1,4).

And let's denote the balance degree of a string as the value of r−lr-l.

Now Dreamoon wants to change exactly kk characters from 'B' to 'A', and he wants to make the balance degree of the string as small as possible.

Please calculate the required minimum possible value of balance degree.

有一个长度为 n+1n+1 的字符串,由字符 'A' 和 'B' 组成。字符串的第一个字符和最后一个字符均为 'A'。

你将得到 mm 个下标 p1,p2,…,pmp_1, p_2, \ldots, p_m(采用 0-起始索引),表示字符串中其余所有字符 'A' 的位置。

记相邻两个 'A' 之间的最小距离为 ll,最大距离为 rr。

例如,字符串 "ABBAABBBA" 的 (l,r)(l,r) 为 (1,4)(1,4)。

我们定义字符串的平衡度为 r−lr - l。

现在 Dreamoon 想要恰好将 kk 个 'B' 字符改为 'A',并希望使字符串的平衡度尽可能小。

请计算所能达到的平衡度的最小可能值。

输入格式

The first line contains one integer tt denoting the number of test cases (1≤t≤400 0001 \leq t \leq 400\,000).

For each test case, the first line contains three integers nn, mm and kk (1≤n≤1015,0≤m≤400 000,0≤k<n−m1 \leq n \leq 10^{15}, 0 \leq m \leq 400\,000, 0 \leq k \lt n - m).

The second line contains mm integers p1,p2,…,pmp_1, p_2, \ldots, p_m, (0<p1<p2<…<pm<n0 \lt p_1 \lt p_2 \lt \ldots \lt p_m \lt n).

The total sum of mm is at most 400 000400\,000.

第一行包含一个整数 tt,表示测试用例的数量(1≤t≤400 0001 \leq t \leq 400\,000)。

对于每个测试用例,第一行包含三个整数 nn、mm 和 kk(1≤n≤1015, 0≤m≤400 000, 0≤k<n−m1 \leq n \leq 10^{15},\ 0 \leq m \leq 400\,000,\ 0 \leq k \lt n - m)。

第二行包含 mm 个整数 p1,p2,…,pmp_1, p_2, \ldots, p_m(0<p1<p2<…<pm<n0 \lt p_1 \lt p_2 \lt \ldots \lt p_m \lt n)。

所有测试用例中 mm 的总和不超过 400 000400\,000。

输出格式

For each test case, print one integer: the smallest possible value of balance degree after kk changes of 'B' to 'A'.

对于每个测试用例,输出一个整数:经过 kk 次将 'B' 改为 'A' 后,平衡度的最小可能值。

输入输出样例

  • 输入#1

    5
    80 3 5
    11 24 50
    81 7 12
    4 10 17 26 37 48 61
    25 10 14
    3 4 7 12 13 15 17 19 21 23
    1 0 0
    
    10 2 0
    2 4

    输出#1

    5
    2
    0
    0
    4

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

首页