MAIN8_C - Shake Shake Shaky
Shaky has N (1 ≤ N ≤ 50000) candy boxes each of them contains a non-zero number of candies (between 1 and 1000000000). Shakey want to distribute these candies among his K (1 ≤ K ≤ 1000000000) IIIT-Delhi students. He want to distribute them in a way such that:
- All students get equal number of candies.
- All the candies which a student get must be from a single box only.
As he want to make all of them happy so he want to give as many candies as possible. Help Shaky in finding out what is the maximum number of candies which a student can get.
Input
First line contains 1 ≤ T ≤ 20 the number of test cases. Then T test cases follow. First line of each test case contains N and K. Next line contains N integers, ith of which is the number of candies in ith box.
Output
For each test case print the required answer in a separate line.
Example
Input: 2 3 2 3 1 4 4 1 3 2 3 9 Output: 3 9
hide comments
|
satoruu:
2016-04-27 17:10:04
Very nice problem! Try to find out the maxium possible number of candies you can give, and find the optimal point from zero to max. AC on my first try :) |
|
minhthai:
2016-02-11 06:07:14
if it's impossible, print 0 |
|
Akshay Aradhya:
2015-07-15 21:41:47
This problem is total BS
|
|
Madhav:
2015-04-07 20:45:14
good concept!! |
|
Kaushik:
2014-03-14 19:27:05
@Joey there is IIIT in Delhi :P |
|
Joey Tribbiani:
2013-07-09 09:58:45
go home mahesh, no IIIT in delhi :P |
|
ginnipkj:
2012-12-14 19:40:26
hint :- You know the value of PIE, then u knw this :D |
|
Nilendu Das:
2012-12-10 10:30:28
Some Clarifications:
|
|
Yashodhan S. Katte:
2012-03-25 07:29:52
for input:
|
|
arshan qureshi:
2012-02-10 15:33:44
i don't know if my algo is wrong , can you provide us with some more test cases ,plz ...or anyone having the correct answer. |
Added by: | Mahesh Chandra Sharma |
Date: | 2011-04-20 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own problem used for NSIT-IIITA Main contest #8 |