Submit | All submissions | Best solutions | Back to list |
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 distibute these candies among his K (1<=K<=1000000000) IIIT-Delhi students. He want to distibute them in a way such that:
1. All students get equal number of candies.
2. 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 seperate line.
Example
Input: 2 3 2 3 1 4 4 1 3 2 3 9 Output: 3 9
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 |
hide comments
|
||||||||
2016-05-06 20:21:37 Dushyant Singh
Can someone give me test case where answer is greater than the greatest number of candies in a box? |
||||||||
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 :) |
||||||||
2016-02-11 06:07:14 minhthai
if it's impossible, print 0 |
||||||||
2015-07-15 21:41:47 Akshay Aradhya
This problem is total BS :D Get it ? |
||||||||
2015-04-07 20:45:14 Madhav
good concept!! |
||||||||
2014-03-14 19:27:05 Kaushik
@Joey there is IIIT in Delhi :P |
||||||||
2013-07-09 09:58:45 Joey Tribbiani
go home mahesh, no IIIT in delhi :P |
||||||||
2012-12-14 19:40:26 ginnipkj
hint :- You know the value of PIE, then u knw this :D |
||||||||
2012-12-10 10:30:28 Nilendu Das
Some Clarifications: 1. It is not necessary that all candies from a box are taken. 2. It may be possible that two persons get candies from a single box as said by @Yashodhan S. Katte 3.N is of order 10^4. When i get such small limits, i always think of a highly modified brute force search. |
||||||||
2012-03-25 07:29:52 Yashodhan S. Katte
for input: 5 4 2 4 1 3 1 answer output: 2 As two persons can get candies from same box.for eg: if a box has 4 candies then can 2 persons get 2 candies each from same box. |