The D. E. Shaw GroupOA #5
Find Number of Interesting Pairs
估计中等可在线判题
Given an integer array and sumVal, an unordered pair (i,j) of distinct indices is called an interesting pair when |arr[i]-arr[j]|+|arr[i]+arr[j]| equals sumVal. Count such pairs.
The standard input/output, the ranges added by this site, and the examples follow this problem's description.
输入格式
The first line contains n and sumVal, and the second line contains n integers. 1≤n≤100000, −10^9≤arr[i]≤10^9, −2×10^9≤sumVal≤2×10^9; the result uses a 64-bit integer.
输出格式
Output the number of unordered index pairs that satisfy the condition.
样例 1
输入:
4 4
1 4 -1 2
输出:
2
样例 2
输入:
3 0
0 0 3
输出:
1
样例 3
输入:
3 4
2 -2 4
输出:
1