Chef And His Society

All submissions for this problem are available.
Chef is an algorithmist so his friend has given him a problem.
Problem is that you have been given an array A(indexed 1 through N). There is a thresold value $Th$. You need to find a maximum integer value M so that $S$ is greater or equal to $Th$.
Where, $S$ = $\sum_{i=1}^{N} max(A_iM,0)$
For example  If $A$ is $1,2,3,4,5,6,7$ and $ Th= 9$, then $M$ will be 3 and
$S = max(13,0) + max(23,0) + max(33,0) + max(43,0) + max(53,0) + max(63,0) + max(73,0)$
i.e, $S=10$ which greater than $Th$.
Chef is very busy with his internship so he ask you to do this for him. You need to print maximum value $M$ as well as $S$.
Input :
 First line will contain $T$, number of testcases. Then the testcases follow.
 Each testcase contains of a single line of input, two integers $N, Th$.
 Third line will contains $A_1, A_2, A_3,..........A_N $ .
Output:
For each testcase, output two space separated integers $M$ and $S$.Constraints
 $ 1\leq T \leq 100$
 $ 2\leq N \leq 100000$
 $ 1\leq Th \leq 10^9$
 $ 1\leq A_i \leq 10^9$
Sample Input:
28 8
10 11 12 13 14 15 16 17
6 6
3 4 5 6 7 8
Sample Output:
13 10
5 6
Author:  dshahid380_ 
Editorial  https://discuss.codechef.com/problems/MDSA 
Tags  binarysearch, dshahid380_, easy, enja2019 
Date Added:  23012019 
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, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions