CF1941F.Rudolf and Imbalance
普及+/提高
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Rudolf has prepared a set of n problems with complexities a1<a2<a3<⋯<an. 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 m models of problems and k functions. The complexity of the i-th model is di, and the complexity of the j-th function is fj. To create a problem, he selects values i and j (1≤i≤m, 1≤j≤k) and by combining the i-th model with the j-th function, he obtains a new problem with complexity di+fj (a new element is inserted into the array a).
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−1 (i>1).
What is the minimum value of imbalance that Rudolf can achieve by adding at most one problem, created according to the described rules?
鲁道夫准备了一组 n 道题目,其难度分别为 a1<a2<a3<⋯<an。他对当前题目的难度分布平衡性并不完全满意,因此希望最多额外添加一道题目来改善它。
为此,鲁道夫准备了 m 种题目模型和 k 种函数。第 i 个模型的难度为 di,第 j 个函数的难度为 fj。要构造一道新题目,他需选定一对下标 i 和 j(其中 1≤i≤m,1≤j≤k),将第 i 个模型与第 j 个函数组合,从而得到一道难度为 di+fj 的新题目(该新难度值将被插入数组 a 中)。
为衡量题集的不平衡程度,鲁道夫将所有题目难度按升序排序,并计算所有相邻差值中的最大值,即 i>1max(ai−ai−1)。
在至多添加一道按上述规则构造的新题目的前提下,鲁道夫所能达到的最小不平衡度是多少?
输入格式
The first line of the input contains a single integer t (1≤t≤104) — the number of testcases.
The first line of each test case contains three integers n, m, and k (2≤n≤105, 1≤m,k≤2⋅105) — the number of prepared problems, the number of models, and the number of functions, respectively.
The second line of each test case contains n integers a1,a2,a3,…an (1≤ai≤2⋅109, ai<ai+1) — the complexities of the prepared problems.
The third line of each test case contains m integers d1,d2,d3,…dm (1≤di≤109) — the complexities of the models.
The fourth line of each test case contains k integers f1,f2,f3,…fk (1≤fi≤109) — the complexities of the functions.
It is guaranteed that the sum of n over all testcases does not exceed 105.
It is guaranteed that the sum of m over all testcases does not exceed 2⋅105.
It is guaranteed that the sum of k over all testcases does not exceed 2⋅105.
输入的第一行包含一个整数 t(1≤t≤104)—— 表示测试用例的数量。
每个测试用例的第一行包含三个整数 n、m 和 k(2≤n≤105,1≤m,k≤2⋅105)—— 分别表示准备好的题目数量、模型数量和函数数量。
每个测试用例的第二行包含 n 个整数 a1,a2,a3,…an(1≤ai≤2⋅109,且 ai<ai+1)—— 表示准备好的题目的难度。
每个测试用例的第三行包含 m 个整数 d1,d2,d3,…dm(1≤di≤109)—— 表示模型的难度。
每个测试用例的第四行包含 k 个整数 f1,f2,f3,…fk(1≤fi≤109)—— 表示函数的难度。
保证所有测试用例中 n 的总和不超过 105。
保证所有测试用例中 m 的总和不超过 2⋅105。
保证所有测试用例中 k 的总和不超过 2⋅105。
输出格式
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测评打分。不知道怎么写?