Floor Sum
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
You are given an array A[] with n elements and an integer S.
You need to find out smallest number X such that,
Floor( \(A1\) / X) + Floor( \(A2\) / X) + Floor( \(A3\) / X) + ... + Floor( \(An\) / X) = S . where X must be greater than 0.
Here floor function means rounded down value,
Floor(\(3/2\))=1,
Floor(\(7/3\))=2.
Floor (\(15/5\))=3.
If there are no such X present,print -1.
Input
The first line contains one positive integer t denoting the number of test cases.
The first line of each test case contains two positive integer n and S.
The second line of each test case contains Array \(A[]\) of length n.
\(1 <= t <= 100\)
\(1 <= n <= 3 * 10^5\)
\(1 <= A[] <= 10^9\)
\(0 <= S <= 10^{12}\)
It is guaranteed that the sum of n over all test cases does not exceed \(3 * 10^5\).
Output
If such number X exist, find smallest X and print it ,otherwise print -1.
Sample
Input | Output |
---|---|
|
|
Information
- ID
- 1057
- Difficulty
- 9
- Category
- (None)
- Tags
- (None)
- # Submissions
- 10
- Accepted
- 4
- Accepted Ratio
- 40%
- Uploaded By