Submit | All submissions | Best solutions | Back to list |
EI2122Q1ADAM1 - Number of pairs |
Given N integers, denoted by numbers, and an integer X. Count the number of pair indices (i, j) that i < j and numbers[j] - numbers[i] = X
Input
- The first line contains two integers N, X (1 ≤ N ≤ 105, -109 ≤ X ≤ 109).
- The second line contains N integers (-109 ≤ numbers[i] ≤ 109).
Output
The number of pair indices.
Sample
Input |
Output |
6 1 1 6 4 2 4 5 |
3
|
Added by: | Ha Minh Ngoc |
Date: | 2021-11-15 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: GOSU |