#2674. 团队竞赛
团队竞赛
Description
信息学竞赛在不同的比赛中,通常有不同的赛制,其中就有一种由 <math xmlns="http://www.w3.org/1998/Math/MathML">3 位选手组队的团体比赛。
现有 <math xmlns="http://www.w3.org/1998/Math/MathML">n 名学生,其中第 <math xmlns="http://www.w3.org/1998/Math/MathML">i 名学生有编程能力值 <math xmlns="http://www.w3.org/1998/Math/MathML">ai ,小爱老师需要从中选出 <math xmlns="http://www.w3.org/1998/Math/MathML">3 名选手参加本次比赛。为了不让团队的实力过于悬殊,他希望选出的 <math xmlns="http://www.w3.org/1998/Math/MathML">3 名选手相互之间能力值之差不超过 <math xmlns="http://www.w3.org/1998/Math/MathML">X。
请你帮助小爱老师计算一下,有多少种组队方法?
(注意:相同的三位学生组队,只计一种选法,即不考虑选出学生相互之间的先后顺序)
Input Format
输入共两行:输入第一行,两个正整数 n,X
输入第一行,<math xm
Output Format
输出只包含一个正整数,表示最终答案的方案数4 20
30 20 10 40
2
Hint
样例说明:
{10,20,30},{20,30,40} 共2中选法
- 对于<math xmlns="http://www.w3.org/1998/Math/MathML">30%的数据,<math xmlns="http://www.w3.org/1998/Math/MathML">1≤n≤100
- 对于<math xmlns="http://www.w3.org/1998/Math/MathML">50%的数据,<math xmlns="http://www.w3.org/1998/Math/MathML">1≤n≤103
- 对于<math xmlns="http://www.w3.org/1998/Math/MathML">100%的数据,<math xmlns="http://www.w3.org/1998/Math/MathML">1≤n≤105 ,<math xmlns="http://www.w3.org/1998/Math/MathML">1≤ai,X≤109