Problem:
Score : 2100 points

Problem Statement

You have a circle of length C, and you are placing N arcs on it. Arc i has length L_i.

Every arc i is placed on the circle uniformly at random:
a random real point on the circle is chosen, then an arc of length L_i centered at this point appears.

Note that the arcs are placed independently. For example, they may intersect or contain each other.

What is the probability that every real point of the circle will be covered by at least one arc?
Assume that an arc covers its ends.

Constraints

2 \leq N \leq 6

2 \leq C \leq 50

1 \leq L_i < C

All input values are integers.

Input

Input is given from Standard Input in the following format:

N C
L_1 L_2 ... L_N

Output

Print the probability that every real point of the circle will be covered by at least one arc.
Your answer will be considered correct if its absolute error doesn't exceed 10^{-11}.

Sample Input 1

2 3
2 2

Sample Output 1

0.3333333333333333

The centers of the two arcs must be at distance at least 1. The probability of this on a circle of length 3 is 1 / 3.

Sample Input 2

4 10
1 2 3 4

Sample Output 2

0.0000000000000000

Even though the total length of the arcs is exactly C and it's possible that every real point of the circle is covered by at least one arc,
the probability of this event is 0.

Sample Input 3

4 2
1 1 1 1

Sample Output 3

0.5000000000000000

Sample Input 4

3 5
2 2 4

Sample Output 4

0.4000000000000000

Sample Input 5

4 6
4 1 3 2

Sample Output 5

0.3148148148148148

Sample Input 6

6 49
22 13 27 8 2 19

Sample Output 6

0.2832340720702695

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.io.*;
import java.util.*;

public class Main {
    FastScanner in;
    PrintWriter out;

    int n, c;
    int[] len;
    double[][][] dp;

    double solve(int[] perm) {
        double[] add = new double[n + 1];
        for (int i = 0; i < perm.length; i++) {
            add[i] = (1 + perm[i]) / (n + 5.);
        }
        double firstProb = 1;
        for (int i = 1; i <= n; i++) {
            firstProb /= i;
        }
        for (int i = 0; i < dp.length; i++) {
            for (int j = 0; j < dp[i].length; j++) {
                for (int k = 0; k < dp[i][j].length; k++) {
                    Arrays.fill(dp[i][j], 0);
                }
            }
        }
        dp[0][0][0] = firstProb;
        double result = 0;
        for (int pos = 0; pos <= c; pos++) {
            for (int mask = 0; mask < 1 << n; mask++) {
                for (int lastIndex = 0; lastIndex < dp[pos][mask].length; lastIndex++) {
                    double cur = dp[pos][mask][lastIndex];
                    if (cur < 1e-20) {
                        continue;
                    }
//                    System.err.println(pos + " " + mask + " " + lastIndex + "->" + cur);
                    int upToPos = (lastIndex - 1) / n;
                    int id = (lastIndex - 1) % n;
                    if (lastIndex == 0) {
                        id = n;
                        upToPos = 0;
                    }
                    double realUpTo = upToPos + len[id] + add[id];
//                    System.err.println("real = " + realUpTo);
                    if (realUpTo >= c) {
                        result += cur;
                        continue;
                    }
                    int notMask = ((1 << n) - 1) ^ mask;
                    for (int useMask = notMask; useMask > 0; useMask = (useMask - 1) & notMask) {
                        double goProb = 1;
                        double goLen = realUpTo;
                        double min = pos + 1;
                        int nextIndex = lastIndex;
                        for (int i = 0; i < n; i++) {
                            if (((1 << i) & useMask) != 0) {
                                goProb /= (c - pos + 0.);
                                min = Math.min(add[i] + pos, min);
                                double go = pos + add[i] + len[i];
                                if (go > goLen) {
                                    goLen = go;
                                    nextIndex = 1 + n * pos + i;
                                }
                            } else if (((1 << i) & notMask) != 0) {
                                goProb *= (c - pos - 1) / (c - pos + 0.);
                            }
                        }
                        if (min > realUpTo) {
                            continue;
                        }
                        int nextMask = mask | useMask;
                        dp[pos + 1][nextMask][nextIndex] += cur * goProb;

                    }

                    if (realUpTo >= pos + 1) {
                        for (int i = 0; i < n; i++) {
                            if (((1 << i) & mask) == 0) {
                                cur *= (c - pos - 1.) / (c - pos);
                            }
                        }
                        dp[pos + 1][mask][lastIndex] += cur;
                    }
                }
            }
        }
//        System.err.println("result = " + result);
//        throw new AssertionError();
        return result;
    }

    double go(int[] perm, boolean[] used, int it) {
        if (it == perm.length) {
            return solve(perm);
        } else {
            double res = 0;
            for (int i = 0; i < perm.length; i++) {
                if (!used[i]) {
                    used[i] = true;
                    perm[it] = i;
                    res += go(perm, used, it + 1);
                    used[i] = false;
                }
            }
            return res;
        }
    }

    void solve() {
        n = in.nextInt();
        c = in.nextInt();
        len = new int[n];
        for (int i = 0; i < n; i++) {
            len[i] = in.nextInt();
        }
        Arrays.sort(len);
        n--;
        dp = new double[c + 1][1 << n][n * c + 1]; // [cur position] [mask used] [current end = (pos * n + index + 1)]
        out.println(go(new int[n], new boolean[n], 0));
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}