1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

const int N = 5e4+9;
const double eps = 0.000000001;
double dp[2][N+N], Q[N];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, t; cin >> n >> t;
    for(int i = -n-1; i <= 0; ++i) {
        dp[0][i+N] = dp[1][i+N] = 1.;
    }
    for(int i = 1; i <= n+1; ++i) {
        dp[0][i+N] = dp[1][i+N] = 0.;
    }
    double res = 0.;
    for(int i = 1; i <= n; ++i) {
        cin >> Q[i];
    }
    sort(Q+1, Q+n+1);
    double prev0 = 0., prev1 = 0.;
    for(int i = n; i >= 1; --i) {
        int k = i&1;
        double p = Q[i];
        for(int j = max(t-i+1, -(n-i+1)); j <= min(t+i-1, n-i+1); ++j) {
            dp[k][j+N] = p*dp[k^1][j-1+N]+(1.-p)*dp[k^1][j+1+N];
        }
        double x = dp[k][t+N];
        if(x >= res)
            res = x;
        else if(x <= prev0-eps && x <= prev1-eps)
            break;
        prev1 = prev0;
        prev0 = x;
    }
    cout << setprecision(7) << fixed << res << "\n";

    return 0;
}