Admins and Shopping Solution | CodeChef Problem Solution 2022
CodeChef admins went on shopping at a shopping mall.
There are shops in the mall where the shop has a capacity of people. In other words, at any point in time, there can be at most number of people in the shop.
There are admins. Each admin wants to visit each of the shops exactly once. It is known that an admin takes exactly one hour for shopping at any particular shop. Find the minimum time (in hours) in which all the admins can complete their shopping.
Note:
- An admin can visit the shops in any order.
- It is possible that at some point in time, an admin sits idle and does not visit any shop while others are shopping.
Input Format
- First line will contain , the number of test cases. Then the test cases follow.
- The first line of each test case contains two integers and - the number of shops and the number of admins.
- The second line of each test case contains integers - the capacity of the shops.
Output Format
For each test case, output in a single line the minimum time (in hours) in which all the admins can complete their shopping.
Constraints
- Sum of over all test cases does not exceed .
Sample Input 1
3
2 3
3 3
4 2
1 2 3 4
1 6
2
Sample Output 1
2
4
3
Explanation
Test case : Minimum time required to complete the shopping is two hours. A possible way to complete shopping in hours is :
- hour: All admins visit shop . This is possible as the capacity of the shop is .
- hour: All admins visit shop . This is possible as the capacity of the shop is .
Test case : Minimum time required to complete the shopping is hours. A possible way to complete shopping in hours is :
- hour: Admin visits shop and admin visits shop .
- hour: Admin visits shop and admin visits shop .
- hour: Admin visits shop and admin visits shop .
- hour: Admin visits shop and admin visits shop .
Test case : Minimum time required to complete the shopping is hours. A possible way to complete shopping in hours is :
- hour: Admins and visits shop . All other admins sit idle.
- hour: Admins and visits shop . All other admins sit idle.
- hour: Admins and visits shop . All other admins sit idle.
Note that, since the capacity of shop is , maximum admins visit the shop at once.
No comments:
Post a Comment