Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@thealchemist627 | 456 |

@dalwainazism125 | 453 |

@akashkale117 | 453 |

@shivanandp12345678910 | 453 |

@codeantik | 448 |

@SherlockHolmes3 | 447 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

Complete Leaderboard |

Given an array A consisting of integers of size N and 2 additional integers K and X, you need to find the number of subsets of this array of size K, where Absolute difference between the **Maximum** and **Minimum** number of the subset is at most X.

As this number that you need to find can be rather large, print it **Modulo** 10^{9}+7

**Input:**

The first line of input contains T denoting the no of test cases . Then T test cases follow . The first line of each test case contains 3 space separated integers denoting N, K and X. The next line contains N space separated values of the array A[ ] .

**Output:**

For each test case output the required result in a new line, print it **Modulo** 10^{9}+7.

**Constraints:**

1≤N≤5×10^{5}

1≤K≤N

1≤A[i],X≤10^{9}

**Example:
Input:**

2

5 3 5

1 2 3 4 5

8 4 6

2 4 6 8 10 12 14 16

10

5

**Explanation :
For the first test case**

Possible subsets of size 3 are {1,2,3} {1,2,4} {1,2,5} {1,3,4} {1,3,5} {1,4,5} {2,3,4} {2,3,5} {2,4,5} {3,4,5} having difference of maximum and minimum element less than equal to 5.

**For the second test case**

Possible subsets of size 4 are {2,4,6,8} {4,6,8,10} {6,8,10,12} {8,10,12,14} {10,12,14,16} having difference of maximum and minimum element less than equal to 6.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Count Number

...