3753. 多集

Multiple Sets

time limit per test:3s

memory limit per test:256MB


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 , Please calculate the minimum .


Input Format:

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 i-th multiple set, followed by  integers with absolute values not exceeding  —— indicating the elements of the i-th multiple set.


Guarantee that for each test case does not exceed, the sum of for all test cases does not exceed .


Output Format:

For each testcase, output an integer representing the answer, which is the minimum .


Input Case

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


Output Case

1
15
0




多集

时间限制: 3s

内存限制:256MB


题目描述

给定  个非空多重集合,每个多重集合只包含绝对值不超过 

要求从每个多重集合中精确选择一个数字,组成一个长度为  的数组 

假设 ,请计算最小  


输入格式

每个测试包含多个测试用例。第一行输入包含一个整数 


每个测试用例的第一行包含一个整数  —— 多个集合的数量。


每个测试用例的后面  行首先读入一个参数  —— 表示第  个多重集合的大小,然后读入绝对值不超过  的  个整数 —— 表示第  个多重集合的元素。


保证每个测试用例的不超过 ,所有测试用例的之和不超过 


输出格式

针对每个测试用例,输出一个代表答案的整数,即最小值 


输入样例

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


输出样例

1
15
0

难度等级: 0
总通过次数: 6
总提交次数: 22