#C8995. Count Distinct Absolute Differences
Count Distinct Absolute Differences
Count Distinct Absolute Differences
Given an array of n integers and an integer K, the goal is to compute the number of distinct absolute differences between every pair of elements in the array such that the difference is at least K. Specifically, for every pair of indices \(1 \le i < j \le n\), calculate the absolute difference \(|arr[i] - arr[j]|\) and count the number of unique differences that satisfy \(|arr[i] - arr[j]| \ge K\).
Input: The first line contains two integers \(N\) and \(K\). The second line contains \(N\) space-separated integers representing the array elements.
Output: Output a single integer which denotes the count of distinct absolute differences that are greater than or equal to \(K\).
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains two integers \(N\) (the number of elements) and \(K\) (the threshold).
- The second line contains \(N\) integers denoting the elements of the array.
outputFormat
Print a single integer to standard output (stdout): the count of distinct absolute differences between any two elements that are at least \(K\) in value.
## sample5 2
1 3 4 7 10
6