#K4966. Closest Jeans Quality Difference

    ID: 28692 Type: Default 1000ms 256MiB

Closest Jeans Quality Difference

Closest Jeans Quality Difference

You are given a list of jeans' quality values and a target difference. For any two jeans with qualities, after sorting them so that for indices i and j with i < j the quality difference is computed as (diff = q_j - q_i), your task is to find the minimum absolute difference between (diff) and the given (target), i.e., compute (\min |diff - target|). If there is no valid pair (i.e. when (n < 2)), output inf.

inputFormat

The input is provided via standard input. The first line contains two integers (n) and (target), where (n) is the number of jeans and (target) is the target difference. The second line contains (n) space‐separated integers, representing the quality values of the jeans.

outputFormat

Output a single value: the minimum absolute difference between the actual difference ((q_j - q_i) with (i < j)) of any pair of jeans and the target difference. If no valid pair exists (i.e., when (n < 2)), print inf.## sample

5 10
3 8 15 1 10
1