cswork / OA打开练习工作台

Goldman SachsOA #31

Project Estimates

估计简单可在线判题

考点(AI 标注)哈希计数

Given distinct project costs and a target difference, count the distinct unordered pairs of values whose absolute difference is exactly target.

输入格式

The first line contains n target (1≤n≤200000, 1≤target≤10^9); the second line contains n distinct positive integer costs (≤2×10^9). Following the original examples, this site sets the lower bound of n to 1.

输出格式

Output the number of unordered pairs of values whose absolute difference equals target.

样例 1

输入:

5 2
1 5 3 4 2

输出:

3

样例 2

输入:

3 2
1 3 5

输出:

2

样例 3

输入:

4 10
1 2 8 12

输出:

1