← Home
```go
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"sort"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func computeCount(A []int64, thresh int64) int64 {
	n := len(A)
	var count int64 = 0
	for i := 0; i < n-1; i++ {
		target := A[i] + thresh
		pos := sort.Search(n, func(x int) bool { return A[x] >= target })
		start := max(i+1, pos)
		if start < n {
			count += int64(n - start)
		}
	}
	return count
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	var l, t int64
	fmt.Fscan(in, &n, &l, &t)
	A := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &A[i])
	}
	sort.Slice(A, func(i, j int) bool { return A[i] < A[j] })
	if n < 2 {
		fmt.Printf("%.10f\n", 0.0)
		return
	}
	q := (2 * t) / l
	mod := (2 * t) % l
	th := l - mod
	y := mod + 1
	countGeTh := computeCount(A, th)
	countGt := computeCount(A, y)

	bigN := big.NewInt(int64(n))
	bigNm1 := big.NewInt(int64(n - 1))
	bigBinom := new(big.Int).Mul(bigN, bigNm1)
	bigBinom.Div(bigBinom, big.NewInt(2))

	bigQ := big.NewInt(q)
	bigBinomQ := new(big.Int).Mul(bigBinom, bigQ)

	bigS1 := new(big.Int).Sub(bigBinomQ, big.NewInt(countGt))
	bigS2 := new(big.Int).Add(bigBinomQ, big.NewInt(countGeTh))

	bigTotal := new(big.Int).Add(bigS1, bigS2)
	bigTotal.Add(bigTotal, bigBinom)

	bfTotal := new(big.Float).SetInt(bigTotal)
	bf4 := new(big.Float).SetFloat64(4.0)
	bfAns := new(big.Float).Quo(bfTotal, bf4)
	ans, _ := bfAns.Float64()
	fmt.Printf("%.10f\n", ans)
}
```