Approximately II

All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
You are given an array of N integers a_{1}, a_{2}, ..., a_{N} and an integer K. Find the number of such unordered pairs {i, j} that
 i ≠ j
 a_{i} + a_{j}  K is minimal possible
Output the minimal possible value of a_{i} + a_{j}  K (where i ≠ j) and the number of such pairs for the given array and the integer K.
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case consists of two space separated integers  N and K respectively.
The second line contains N single space separated integers  a_{1}, a_{2}, ..., a_{N} respectively.
Output
For each test case, output a single line containing two single space separated integers  the minimal possible value of a_{i} + a_{j}  K and the number of unordered pairs {i, j} for which this minimal difference is reached.
Constraints
 1 ≤ T ≤ 50
 1 ≤ a_{i}, K ≤ 10^{9}
 N = 2  31 point.
 2 ≤ N ≤ 1000  69 points.
Example
Input: 1 4 9 4 4 2 6 Output: 1 4
Explanation:
The minimal possible absolute difference of 1 can be obtained by taking the pairs of a_{1} and a_{2}, a_{1} and a_{4}, a_{2} and a_{4}, a_{3} and a_{4}.
Author:  xcwgf666 
Tester:  stzgd 
Editorial  http://discuss.codechef.com/problems/APPROX2 
Tags  cakewalk, ltime12, xcwgf666 
Date Added:  27042014 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, 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, PERL6, TEXT, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 