BETA

Difficulty Level: Easy

Submissions: 1029 Accuracy:

2.62%

Adding Array Elements
       

We are given a list of N unsorted elements, we need to find minimum number of steps in which the elements of the list can be added to make all the elements greater than or equal to K. We are allowed to add two elements together and make them one.

Examples:

Input : arr[] = {1 10 12 9 2 3}
          K = 6
Output : 2
First we add (1 + 2), now the new list becomes 
3 10 12 9 3, then we add (3 + 3),  now the new 
list becomes 6 10 12 9, Now all the elements in 
the list are greater than 6. Hence the output is 
2 i:e 2 operations are required 
to do this. 

Input :  The first line of input contains an integer T denoting the Test cases. Then T test cases follow.  Second line contains no. of array elements - N and K Third line array elements A[i] 

Output : 
Print minimum number of steps. If it is not possible to make elements greater than or equal to K, print "-1".

Constraints :
1 ≤ T ≤ 50
1 ≤ N, K ≤ 10^5
1 ≤ A[i] ≤ 10^6

Input : 
1
6 6
1 10 12 9 2 3 

Output : 
2

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Mohit Gupta_OMG :)

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.