题解 | 小红的整数配对
小红的整数配对
https://www.nowcoder.com/practice/66b9810e4fe34956a8d1f5c67aacc6dc
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
i = n-1
score = 0
while i>=1:
if abs(a[i]-a[i-1])<=k:
score += a[i]*a[i-1]
i-=2
else:
i-=1
print(score)
