Raghav in Auction

3.2

8 votes
Problem

Raghav is big fan of cricket and he is going to the auction of Sachin's Bat. The auction committee will invite at max M bidders. There are total N bidders including raghav. The standard of each bidder is defined by the value of assets he posses. The Auction has an opening bid O, a bidder is invited only if his total value of assets is greater than or equal to the opening bid. You are given the values of assets of each bidder. Please tell whether Raghav will be invited or not. If Raghav is invited output P, where P is the total number of bidders that are being invited, otherwise output -1. Input

The first line contains T, the number of test case. The first line of each test case contain three space separated numbers N M O. Then the second line contain N space separated integers A1, A2, A3, ......., AN. A1 is the value of assets, Raghav possesses.

For each test case output the required answer in a new line. Constraints

1 <= T <= 10 1 <= N <= 100000 1 <= M <= 100000 1 <= O <= 1000000000 1 <= Ai <= 1000000000

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

In the first test case, O is 4 but Raghav does not have enough assets, hence the output is -1. In the second case, it is clear that Raghav and one other will join the bid, hence output 2.

Editor Image

?