Submit | All submissions | Best solutions | Back to list |
PAIRS1 - Count the Pairs |
Given N integers [0 < N <= 10^5], count the total pairs of integers that have a difference of K. (Everything can be done with 32 bit integers).
Input
1st line contains integers N and K.
2nd line contains N integers of the set. All the N numbers are distinct.
Output
One integer - the number of pairs of numbers that have a difference of K.
Example
Input: 5 2 1 5 3 4 2 Output: 3
Input: 10 1 363374326 364147530 61825163 1073065718 1281246024 1399469912 428047635 491595254 879792181 1069262793 Output: 0
Added by: | psn |
Date: | 2013-10-18 |
Time limit: | 0.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C++ 4.3.2 CPP CPP14 JAVA |
Resource: | Own |