SalesforceOA #21
Get Perfect Pairs Count
估计中等可在线判题
Count the index pairs with 0≤i<j<n that satisfy both min(|x−y|,|x+y|)≤min(|x|,|y|) and max(|x−y|,|x+y|)≥max(|x|,|y|), where x=a[i] and y=a[j]. Repeated values are counted separately by index.
输入格式
The input gives n and n integers. Full original bounds: 2≤n≤200000, −10^9≤a[i]≤10^9; the raw source restores the i<j condition that the catalog's HTML filtering swallowed.
输出格式
Output one integer answer.
样例 1
输入:
3
2 5 -3
输出:
2
样例 2
输入:
3
0 0 1
输出:
1
样例 3
输入:
3
-2 4 -5
输出:
2
样例说明
The outputs of the three public examples are, in order: 2; 1; 2. They have been checked by independent enumeration or direct simulation.