
The first line contains a single integer ‘T’ representing the number of test cases. The 'T' test cases follow.
The first line of each test case will contain two space-separated integers ‘N’, and ‘K’ which denotes the number of machines and the total number of products, respectively.
The next line contains the ‘N’ space-separated integers, where ‘i-th’ element denotes the time taken by ‘i-th’ machine to produce one product.
For each test case, print an integer denoting the minimum time required to produce ‘K’ products.
Output for every test case will be printed in a separate line.
You do not need to print anything; It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 100000
1 <= K, ARR[i] <= 10^9
Where 'ARR[i]' denotes the 'ith' element of ARR.
Time limit: 1 sec
We will iterate over the time from 1 to 10 ^ 18 and check the number of products produced till this time. For, given constraints, 10 ^ 18 is the maximum time machines will take to produce ‘K’ products.
To calculate the number of products produced we will go through all the machines and add the products produced by this machine.
We will use binary search to find the required time efficiently. We will initialize the range of time from 1 to 10 ^ 18. For the given constraints, 10 ^ 18 is the maximum time machines will take to produce ‘K’ products.
For each range of time, we will find its middle value and calculate the number of products produced till the middle.
To calculate the number of products produced we will go through all the machines and add the products produced by this machine till the middle. Depending on the value of products produced, update the range of time.