cswork / OA打开练习工作台

AmazonOA #235

Get Number of Teams

估计中等可在线判题

考点(AI 标注)双指针滑窗二分查找

Choose two different employees; different indices mean different people, even when their skills are equal. Count the unordered employee pairs whose skill sum lies in the closed range [minSkill,maxSkill].

输入格式

The first line contains n minSkill maxSkill; the second line contains the skills. The original constraints were truncated; this site uses 1≤n≤200000, skills and both bounds in −10^9..10^9, and minSkill≤maxSkill.

输出格式

Output a single integer, the answer.

样例 1

输入:

4 5 7
2 3 4 5

输出:

4

样例 2

输入:

3 2 2
1 1 1

输出:

3

样例 3

输入:

3 -2 0
-2 0 2

输出:

2

样例说明

The answers are 4, 3 and 2. In the second example three employees with the same skill form three pairs.