CF1941F.Rudolf and Imbalance

普及+/提高

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Rudolf has prepared a set of nn problems with complexities a1<a2<a3<⋯<ana_1 \lt a_2 \lt a_3 \lt \dots \lt a_n. He is not entirely satisfied with the balance, so he wants to add at most one problem to fix it.

For this, Rudolf came up with mm models of problems and kk functions. The complexity of the ii-th model is did_i, and the complexity of the jj-th function is fjf_j. To create a problem, he selects values ii and jj (1≤i≤m1 \le i \le m, 1≤j≤k1 \le j \le k) and by combining the ii-th model with the jj-th function, he obtains a new problem with complexity di+fjd_i + f_j (a new element is inserted into the array aa).

To determine the imbalance of the set, Rudolf sorts the complexities of the problems in ascending order and finds the largest value of ai−ai−1a_i - a_{i - 1} (i>1i \gt 1).

What is the minimum value of imbalance that Rudolf can achieve by adding at most one problem, created according to the described rules?

鲁道夫准备了一组 nn 道题目,其难度分别为 a1<a2<a3<⋯<ana_1 \lt a_2 \lt a_3 \lt \dots \lt a_n。他对当前题目的难度分布平衡性并不完全满意,因此希望最多额外添加一道题目来改善它。

为此,鲁道夫准备了 mm 种题目模型和 kk 种函数。第 ii 个模型的难度为 did_i,第 jj 个函数的难度为 fjf_j。要构造一道新题目,他需选定一对下标 ii 和 jj(其中 1≤i≤m1 \le i \le m,1≤j≤k1 \le j \le k),将第 ii 个模型与第 jj 个函数组合,从而得到一道难度为 di+fjd_i + f_j 的新题目(该新难度值将被插入数组 aa 中)。

为衡量题集的不平衡程度,鲁道夫将所有题目难度按升序排序,并计算所有相邻差值中的最大值,即 max⁡i>1(ai−ai−1)\max\limits_{i > 1} (a_i - a_{i - 1})。

在至多添加一道按上述规则构造的新题目的前提下,鲁道夫所能达到的最小不平衡度是多少?

输入格式

The first line of the input contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of testcases.

The first line of each test case contains three integers nn, mm, and kk (2≤n≤1052 \le n \le 10^5, 1≤m,k≤2⋅1051 \le m, k \le 2 \cdot 10^5) — the number of prepared problems, the number of models, and the number of functions, respectively.

The second line of each test case contains nn integers a1,a2,a3,…ana_1, a_2, a_3, \dots a_n (1≤ai≤2⋅1091 \le a_i \le 2 \cdot 10^9, ai<ai+1a_i \lt a_{i+1}) — the complexities of the prepared problems.

The third line of each test case contains mm integers d1,d2,d3,…dmd_1, d_2, d_3, \dots d_m (1≤di≤1091 \le d_i \le 10^9) — the complexities of the models.

The fourth line of each test case contains kk integers f1,f2,f3,…fkf_1, f_2, f_3, \dots f_k (1≤fi≤1091 \le f_i \le 10^9) — the complexities of the functions.

It is guaranteed that the sum of nn over all testcases does not exceed 10510^5.

It is guaranteed that the sum of mm over all testcases does not exceed 2⋅1052 \cdot 10^5.

It is guaranteed that the sum of kk over all testcases does not exceed 2⋅1052 \cdot 10^5.

输入的第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 表示测试用例的数量。

每个测试用例的第一行包含三个整数 nn、mm 和 kk(2≤n≤1052 \le n \le 10^5,1≤m,k≤2⋅1051 \le m, k \le 2 \cdot 10^5)—— 分别表示准备好的题目数量、模型数量和函数数量。

每个测试用例的第二行包含 nn 个整数 a1,a2,a3,…ana_1, a_2, a_3, \dots a_n(1≤ai≤2⋅1091 \le a_i \le 2 \cdot 10^9,且 ai<ai+1a_i \lt a_{i+1})—— 表示准备好的题目的难度。

每个测试用例的第三行包含 mm 个整数 d1,d2,d3,…dmd_1, d_2, d_3, \dots d_m(1≤di≤1091 \le d_i \le 10^9)—— 表示模型的难度。

每个测试用例的第四行包含 kk 个整数 f1,f2,f3,…fkf_1, f_2, f_3, \dots f_k(1≤fi≤1091 \le f_i \le 10^9)—— 表示函数的难度。

保证所有测试用例中 nn 的总和不超过 10510^5。

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

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

输出格式

For each testcase, output a single number — the minimum imbalance that Rudolf can achieve.

对于每个测试用例,输出一个数字——鲁道夫能够达到的最小不平衡度。

输入输出样例

  • 输入#1

    7
    5 5 5
    5 10 15 20 26
    11 14 16 13 8
    16 4 5 3 1
    7 6 5
    1 4 7 10 18 21 22
    2 3 5 7 4 2
    6 8 9 3 2
    7 6 5
    1 4 7 10 18 21 22
    2 3 5 7 4 2
    6 8 13 3 2
    5 6 3
    2 10 13 20 25
    11 6 10 16 14 5
    6 17 15
    4 2 2
    11 12 14 15
    19 14
    10 6
    8 4 2
    3 10 16 18 21 22 29 30
    9 13 16 15
    4 2
    2 4 7
    4 21
    4 15 14 5
    20 1 15 1 12 5 11

    输出#1

    5
    4
    5
    8
    2
    7
    11

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

首页