Maximum Prize

1

1 votes
Problem

Recently Ram got to know about a secret place where he can play many games to win lot of prize. Games are very easy, so he can easily win high prize, but he can play a limited number of games. He want to win the maximum amount of prize.So he wants to choose games, such that the prize money is maximum.

Assume that he wins the game if he choose to play that game.

There are n games and he can play maximum k games.

I th game is having a[i] prize money, help him to find maximum amount of prize money that he can win.

Note :

  1. There is atleast one game.
  2. Each game can be played atmost one time.

Constraints :

T <= 10

N <= 10^5

k <= 10^5

a[i] <= 10^6

Input :

First line contain number of test cases t.

Each test case consist of two lines.

First line of each test case consist of two integer n and k.

Second line of each test case consist n space separated integers a[i].

Output:

Output t line each line consisting of the maximum prize that he can win.

To be eligible for prizes you have to register for AlgoXtreme at the Zeitgeist site. To register visit Zeitgeist. Only those candidates who have registered on the Zeitgeist website for the AlgoXtreme contest will be eligible to avail the Prizes.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For the first test case, he can play all the games so the prize is 5.

For the second test case, he can play none of the games so the prize is 0.

Editor Image

?