You have some cards. An integer between 1 and n is written on each card: specifically,…
- User
You have some cards. An integer between 1 and n is written on each card: specifically, for each i from 1 to n , you have ai cards which have the number i written on them.
There is also a shop which contains unlimited cards of each type. You have k coins, so you can buy at most k new cards in total, and the cards you buy can contain any integer between 1 and n , inclusive.
After buying the new cards, you must partition all your cards into decks, according to the following rules:
all the decks must have the same size; there are no pairs of cards with the same value in the same deck. Find the maximum possible size of a deck after buying cards and partitioning them optimally.
Input Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104 ). The description of the test cases follows.
The first line of each test case contains two integers n , k (1≤n≤2⋅105 , 0≤k≤1016 ) — the number of distinct types of cards and the number of coins.
The second line of each test case contains n integers a1,a2,…,an (0≤ai≤1010 , ∑ai≥1 ) — the number of cards of type i you have at the beginning, for each 1≤i≤n .
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
Output For each test case, output a single integer: the maximum possible size of a deck if you operate optimally. solve this using c++ and use int128 for binary seach
- Assistant