#C6609. Minimum Range Subsequence

    ID: 50388 Type: Default 1000ms 256MiB

Minimum Range Subsequence

Minimum Range Subsequence

You are given a sequence of non-negative integers. Your task is to find a subsequence such that the difference between its maximum and minimum elements is minimized. In this problem, the subsequence is the entire sequence, and you need to compute the minimum absolute difference between any two elements.

The minimum difference is defined as \(\min_{1 \le i < j \le n} |a_i - a_j|\). Note that if the sequence contains only one element, the minimum difference is considered to be 0.

For example, given the sequence [4, 2, 1, 10, 5], after sorting it becomes [1, 2, 4, 5, 10], and the minimum difference is \(\min\{1, 2, 1, 5\} = 1\). The output for this case will be the pair: (5, 1) where 5 is the number of elements and 1 is the minimum difference.

inputFormat

The input begins with a single integer \(T\) representing the number of test cases. Each test case is described in two lines:

  • The first line contains a single integer \(n\), the number of elements in the sequence.
  • The second line contains \(n\) space-separated non-negative integers.

outputFormat

For each test case, output a single line containing two space-separated integers: the length of the sequence (\(n\)) and the minimum difference between any two elements in the sequence (as defined above).

## sample
5
1
7
3
2 2 2
5
4 2 1 10 5
6
6 3 9 1 4 7
2
5 8
1 0

3 0 5 1 6 1 2 3

</p>