So Many Books, So Little Time
All submissions for this problem are available.Murphy Cooper has taken time off from solving the gravity equation and has decided to prepare for the International Physics Olympiad. She has a team of $N$ fellows (including you), preparing for the Olympiad. The total level of preparation of a person is directly proportional to the number of books they have in hand. She decides to approach her professor Dr Brand, to get books from him. She takes $k$ people with her. To convince him to give books, you decide to convince him by making the following argument: “To maximize our team’s chances, we require that all of my $k$ teammates here are equally prepared. The person with maximum number of books is Murphy and she has $x$ books more than me. To equalize my preparation to her, I need exactly $x$ more books for myself.” All your friends decide to use the above argument when they are in need of books. Calculate the maximum number of books that Murphy and her friends can get from the professor by taking any $k$ people with her. Remember that the professor does not like big crowds, so you have to take a minimal number of people corresponding to the maximum value of number of books. ###Input format - The first line contains $T$, the number of test cases. - In each test case, the first line has an integer $N$, the size of Murphy’s team. - The second line has $N$ space separated integers $a_1$,$a_2$,...,$a_N$, which are the number of books each of her teammates possesses. ###Constraints - $1 \leq T \leq 10$ - $1 \leq N \leq 100$ - $1 \leq a_i \leq 100$ ###Output format For each test case, print one line having two integers, denoting the maximum number of books she can get from the professor, and the corresponding minimal number of people that go to meet the professor. ###Sample Input 2 2 1 5 5 4 4 4 4 5 ###Sample Output 4 2 4 5
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.