#P9831. Simple Set Problem
Simple Set Problem
Simple Set Problem
Problem Description
Given non empty multiple sets, each multiple set only contains integers with absolute values not exceeding . It is required to select exactly one number from each multiple set to form an array with a length of . Assuming $d=\max(a_1, a_2,\dots,a_k) - \min(a_1, a_2,\dots,a_k)$.Please calculate the minimum .
Input
Each test contains multiple test cases.The first line of input contains a single integer ---the number of test cases.The description of test cases follows. The first line of each test case contains a single integer —— the number of multiple sets. The following lines of each test case first read in a parameter —— indicating the size of the -th multiple set, followed by integers with absolute values not exceeding —— indicating the elements of the -th multiple set. Guarantee that for each test case does not exceed , the sum of for all test cases does not exceed .
Output
For each testcase, output an integer representing the answer, which is the minimum .
Sample Input
3
2
1 6
3 -7 7 10
4
9 -5 -9 2 8 5 4 3 3 8
2 10 8
1 -7
3 1 6 10
1
1 9
Sample Output
1
15
0
Source
2023“钉耙编程”中国大学生算法设计超级联赛(4)