Raju and coins
https://practice.geeksforgeeks.org/problems/raju-and-coins/0
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.
Input:
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.
Output:
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.
Constraints:
1<=T<=27
1<=n<=100000
1<=k<=109
1<=ai<=109
Example:
Input
2
4 14
4 6 12 8
3 7
1 3 4
Output
4
2
用一个数组记录下一个,可选的硬币的位置
1 |
|