How many Topics

All submissions for this problem are available.
ZCO is approaching, and you want to be well prepared! There are $N$ topics to cover and the $i^{th}$ topic takes $H_i$ hours to prepare (where $1 \le i \le N$). You have only $M$ days left to prepare, and you want to utilise this time wisely. You know that you can't spend more than $S$ hours in a day preparing, as you get tired after that. You don't want to study more than one topic in a day, and also, don't want to spend more than two days on any topic, as you feel that this is inefficient. Given these constraints, can you find the maximum number of topics you can prepare, if you choose the topics wisely? ###Input:  First line will contain $T$, number of testcases. Then the testcases follow.  The first line of each test case contains three spaceseparated integers: $N$, $M$ and $S$, denoting the number of topics, the number of days remaining and the number of hours you can study in a day.  The second line of each test case contains $N$ spaceseparated integers $H_i$, denoting the number of hours needed to prepare for the $i^{th}$ topic. ###Output: For each testcase, output in a single line: the maximum number of topics you can prepare. ###Constraints  $1 \leq T \leq 10$  $1 \leq N \leq 10^5$  $1 \leq M \leq 10^5$  $1 \leq S \leq 16$  $1 \leq H_i \leq 50$ ###Subtasks  30 points : Every topic takes the same number of hours to prepare (i.e. all $H_i$ are equal).  70 points : Original constraints. ###Sample Input: ``` 2 5 4 10 10 24 30 19 40 5 4 16 7 16 35 10 15 ``` ###Sample Output: ``` 2 4 ``` ###Explanation: **Testcase 1:** You can choose topics $1$ and $4$. Topic $1$ will consume a single day , while topic $4$ will consume two days. Thus, you'll be able to prepare these two topics within the 4 remaining days. But you can check that you cannot do any better. **Testcase 2:** You can choose topics $1$, $2$, $4$, and $5$. Each of them will consume one day each. Thus you'll be able to cover $4$ topics.Author:  akash_adm 
Tags  akash_adm 
Date Added:  31102019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, 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, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, 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. 