306240: CF1166C. A Tale of Two Lands
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
A Tale of Two Lands
题意翻译
给定序列 $a_1,a_2,a_3,\cdots,a_n$($2 \leq n \leq 10^5$)。求满足如下两个条件中的至少一个的 **无序** 数对 $\{i,j\}$($i \neq j$)的数量: - $|a_i|-|a_j|\leq \min(|a_i|,|a_j|),|a_i|+|a_j|\geq \max(|a_i|,|a_j|)$ - $|a_i+a_j|\leq \min(|a_i|,|a_j|),|a_i-a_j|\geq \max(|a_i|,|a_j|)$ 感谢 @Qiuly 提供翻译题目描述
The legend of the foundation of Vectorland talks of two integers $ x $ and $ y $ . Centuries ago, the array king placed two markers at points $ |x| $ and $ |y| $ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $ |x - y| $ and $ |x + y| $ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland. Here $ |z| $ denotes the absolute value of $ z $ . Now, Jose is stuck on a question of his history exam: "What are the values of $ x $ and $ y $ ?" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $ n $ integers $ a_1, a_2, \dots, a_n $ . Now, he wants to know the number of unordered pairs formed by two different elements from these $ n $ integers such that the legend could be true if $ x $ and $ y $ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 2 \le n \le 2 \cdot 10^5 $ ) — the number of choices. The second line contains $ n $ pairwise distinct integers $ a_1, a_2, \dots, a_n $ ( $ -10^9 \le a_i \le 10^9 $ ) — the choices Jose is considering.
输出格式
Print a single integer number — the number of unordered pairs $ \{x, y\} $ formed by different numbers from Jose's choices that could make the legend true.
输入输出样例
输入样例 #1
3
2 5 -3
输出样例 #1
2
输入样例 #2
2
3 6
输出样例 #2
1