Penny and Candies

All submissions for this problem are available.
Penny pretends to be very smart. Her friend Sheldon gives her a task to test her smartness level. Sheldon gives her $N$ candies. Each $ith$ candy has a label $Ai$ showing its sweetness level. Penny has to put exactly $K$ candies in a box such that the box has balanced sweetness. The balanced sweetness here means that the sweetest candy in the box should not be sweeter than $P$ times the least sweetest candy in the box. As it seemed very easy so Sheldon makes the problem challenging by asking her the total number of ways in which these candies can be put into the box, satisfying above conditions. As the answer can be very large, output the answer modulo $1000000007(10^9+7).$ __NOTE: More than one candy can have same sweetness level.__  ###INPUT:  The first line will contain an integer $T$, the number of test cases. Then the T test cases follow.  The first line of each test case contains three integers $N, P, K$ respectively.  The second line of each test case contains $N$ integers denoting the sweetness level $Ai$ of ith candy.  ###OUTPUT: For each test case, output the answer modulo $1000000007(10^9+7)$ in a new line.  ###Constraints:  $1 \leq T \leq 10$  $1 \leq N \leq 10^5$  $1 \leq P \leq 10^5$  $1 \leq K \leq N$  $1 \leq Ai \leq 10^9$  ###Sample Input: 1 5 3 2 1 2 3 4 5  ###Sample Output: 8  ###EXPLANATION: The total ways to fill the box are as follows __(1,2) , (1,3) , (2,3) , (2,4 ), (2,5) , (3,4) , (3,5) , (4,5)__Author:  p_unit 
Editorial  https://discuss.codechef.com/problems/COG1801 
Tags  codigo2k18, easy, p_unit 
Date Added:  20112018 
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, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions