Raju and coins
Submissions: 1558   Accuracy:


  Difficulty: Easy   Marks: 2

Raju always like to collect coins. Raju has already managed to collect n different types of coins a1,a2....an . One day he went into the sale and find out that the sale consists of 109 types of coins where i-th type of coin costs i dollars. He decided to buy some more different types of coins given that he does not have that type of coin already. But he has only k dollars to spend.
So help him to choose the type of coins.



The first line will contain test cases T. Then T Test cases follow. Each of the test cases will contain two integers n, k   the number of types of coins that Raju already has and the money he has respectively. The next line contains n distinct integers a1,a2...an the types of coins that Raju already has.


Print a single integer denoting the number of different types of coins that Raju can buy so that the number of different coins in his collection is maximum. Cost should not exceed k.




4 14                           
4 6 12 8                        
3 7                             
1 3 4



For the second test case Raju should buy two coins: one coin of the 2-nd type and one coin of the 5-th type. For any other purchase for 7 dollars(assuming that the coins of types 1, 3 and 4 have already been bought), it is impossible to buy more than two coins.


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

Contributor: vaibhav garg
Author: justrelax

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

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

to report an issue on this page.