Keshri's Computer

0

0 votes
Easy
Problem

Keshri has developed his own computer. Inside his system, there are n processors.

Keshri is very lazy, he wants to complete all his q homeworks with the help of his machine. Despite of the length of the homeworks, a processor i can complete a given homework in p[i] amount of time. 

Since Keshri is a very busy person he wants to complete all his homeworks in minimum amount of time. Help Keshri in doing so.

Note: A single processor cannot do more than one task at a time.

Input:

First line of input contains t - the number of test cases. Each test case goes as follows - 
The first line contains two space-separated integers - q and n.
The second line contains n space-separated integers, the ith integer is p[i].

Output:

Print t lines, the minimum amount of time needed by Keshri to complete all his homeworks.

Constraints:

1 <= t <= 50
1 <= n <= 10^5
1 <= q <= 10^6
1 <= p[i] <= 10^9

Sample Input
2
1 2
10 20
3 3
1 2 3
Sample Output
10
2
Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?