Lumpy  The Bus Driver

All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Lumpy is a bus driver. Today, the conductor is absent so Lumpy has to do the conductor's job as well. There are N creatures in the bus. Sometimes the creatures don't carry change and can't pay the exact amount of the fare. Each creature in the bus today has paid an amount greater than his/her fare. You are given information about the extra amount paid by each creature, by an array A of size N, where A_{i} denotes the extra amount paid by the ith creature, in rupees.
After the end of the trip, Lumpy noticed that he had P one rupee coins and Q two rupee coins. He wants to pay back the creatures using this money. Being a kind hearted moose, Lumpy wants to pay back as many creatures as he can. Note that Lumpy will not pay back the ith creature if he can't pay the exact amount that the ith creature requires with the coins that he possesses.
Lumpy is busy driving the bus and doesn't want to calculate the maximum number of creatures he can satisfy  He will surely cause an accident if he tries to do so. Can you help him out with this task?
Input
 The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
 For each test case, first line consists of three space separated integers N, P and Q.
 Second line consists of N space separated integers A containing N space integers, where ith integer denotes A_{i}.
Output
 For each test case, output a single line containing an integer corresponding to maximum number of creatures that Lumpy can pay back.
Constraints
 1 ≤ T ≤ 10^{6}
 1 ≤ N ≤ 10^{5}
 1 ≤ A_{i} ≤ 10^{9}
 0 ≤ P, Q ≤ 10^{14}
 Sum of N over all the cases does not exceed 10^{6}
Subtasks
 Subtask #1 (15 points): P = 0
 Subtask #2 (15 points): Q = 0
 Subtask #3 (70 points): Original constraints
Example
Input: 3 3 3 0 1 2 2 3 2 1 1 2 1 4 5 4 2 3 4 5 Output: 2 3 3
Explanation
Example 1. Lumpy has just 3 one rupee coins. He can pay creatures numbered {1, 2} or creatures numbered {1, 3} with these coins. Thus, answer is 2.
Example 2. Lumpy has 2 one rupee coins and 1 two rupee coin. In the optimal solution, Lumpy can give the two rupee coin to creature 2 and the one rupee coins to creatures 1 and 3. Thus, answer is 3.
Author:  admin2 
Tester:  pushkarmishra 
Editorial  http://discuss.codechef.com/problems/LUMPYBUS 
Tags  admin2, easy, greedy, ltime38 
Date Added:  29072016 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 