Submeter | Todas submissőes | Melhores | Voltar |
Problem hidden
HACKRNDM - Hacking the random number generator |
You recently wrote a random number generator code for a web application and now you notice that some cracker has cracked it. It now gives numbers at a difference of some given value k more predominantly. You being a hacker decide to write a code that will take in n numbers as input and a value k and find the total number of pairs of numbers whose absolute difference is equal to k, in order to assist you in your random number generator testing.
NOTE: All values fit in the range of a signed integer, n, k ≥ 1
Input
1st line contains n and k.
2nd line contains n numbers of the set. All the n numbers are assured to be distinct.
(Edited: n ≤ 105)
Output
One integer saying the number of pairs of numbers that have a difference of k.
Example
Input: 5 2
1 5 3 4 2 Output: 3
Adicionado por: | vijay |
Data: | 2011-10-15 |
Tempo limite: | 1s |
Tamanho do fonte: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Linguagem permitida: | Todas exceto: ASM64 CLOJURE ERL FSHARP PERL6 PY_NBC SCALA TCL |
Origem: | Own Problem |