Xenny and Questions
Tag(s):

Greedy, Sorting, Very-Easy

Problem
Editorial
Analytics

Today Xenny has an exam and he is reading the question paper. He has worked very hard for this and he absolutely knows everything. But there is one thing that he didn't practice and that is - writing speed. Xenny is aware of this and is asking for your help. Xenny knows that he will definitely need 1 unit time for solving each question. Obviously, having studied so hard, he wants to maximize his marks. Your job is to tell him what are the maximum marks can he get if he chooses the right set of questions. Formally, there are N questions in the paper. ith question carries ai marks. Tell Xenny the maximum marks he can get by correct selection of questions.

Hint: Use fast I/O methods.

Input:

The first line of input will contain an integer - T, i.e. number of testcases.

T lines follow.

The format for each test case will be as follows:

First line will contain 2 space-separated integers - N, denoting the no. of questions and K, denoting the amount of time remaining in seconds. Each of the next N lines contains an integer, where integer on ith line denotes marks for ith question.

Output:

For each testcase, print the maximum marks Xenny can get if he chooses the questions optimally.

(Assume Xenny solves every question he chooses correctly :P )

Constraints:

N >= 0

ai >= 0 for 0 <= i < N

SMALL:

1 <= T <=1000, N <= 100, ai <= 100

MEDIUM:

1 <= T <= 100, N <= 1000, ai <=100000

LARGE:

1 <= T <= 100, N <= 100000, ai <=100000

SAMPLE INPUT
2
3 3
1 2 3
2 1
3 4
SAMPLE OUTPUT
6
4
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...