Showing:
Handle Score
@Ibrahim Nash 5725
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Mega Sale
Basic Accuracy: 19.05% Submissions: 5565 Points: 1

Mr. Geek is a greedy seller. He has a stock of N laptops which comprises of both useful and useless laptops. Now, he wants to organize a sale to clear his stock of useless laptops. The prices of N laptops are Ai each consisting of positive and negative integers (-ve denoting useless laptops). In a day, he can sell atmost M laptops. Mr. Geek being a greedy seller want to earn maximum profit out of this sale. So, help him maximizing his profit by selling useless laptops.

Input:
The first line of input contains number of testcases T. For each testcase, there will be two lines of input. Th first line contains two integers N and M. The second line contains prices of N laptops.

Output:
The maximum profit Mr. Geek can earn in a single day.

Constraints:
1 <= T <= 30
1 <= N ≤ 105
1 <= M <= 105
-1012 <= Ai <= 1012

Sample Input:
2
4 3
-6 0 35 4
5 3
-1 -2 -3 -4 5

Sample Output:
6
9

Explanation:
Testcase 1:

Geek sells the laptops with price -6 and earns Rs. 6 as profit.
Testcase 2:
Geek sells the laptops with price -2, -3 and -4 and earns Rs. 9 as profit.