资 源 简 介
Given a set of N numbers (N ≤ 105), we need to count the total pairs of numbers that have a difference of K (0 < K < 109).
Input
Input will consist of multiple test cases. Each test case will consist of two lines.
The first line will contain two positive integers in the format N K. The first specifies how many numbers are in the set and the second is the desired difference.
The second line contains the N numbers of the set, each separated by a single space. All of the N numbers are assured to be distinct.
Output
For each test case, output a single line with one integer representing how many pairs of numbers from the set have a difference of K.
Sample Input
5 2
1 5 3 4 2
9 1
363374326 364147530 61825163 1073065718 1281246024 1399469912 428047635 491595254 879792181
Sample Output
3
0