Problem hidden on 2013-10-03 22:19:18 by Mitch Schwartz
COUNTIT - Count the bugs
Michael recently wrote a small piece of code that generates n random numbers. But he found out that the random number generator has a major bug. He observed that in any series ,numbers with a difference of k are often repeated. So he decided to find out that in a series of random numbers how many pairs have a difference of k.
Input
1st line consists of an integer T -no. of test cases
For each test case,
1st line contains -> n & k(n<=25000,1<=k<=n)
2nd line -> array of random numbers (all elements will fit into int)
Output
An integer containing the required answer.
Example
Input: 1
5 3
1 4 2 3 5
Output:
2
Explanation : 1 and 4, 2 and 5 are the only pairs with their difference as 3.
Added by: | n.7n |
Date: | 2013-09-22 |
Time limit: | 0.5s-1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Common problem |