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
47
48
49
50
51
52
53
#include <bits/stdc++.h>

using namespace std;

#define st first
#define nd second
#define pb push_back
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define irep(i,a,b) for(int i = a; i >= b; i--)
typedef long long ll;
typedef long double ld;
//typedef __int128 int128;
typedef vector<int> vi;
typedef pair<int,int> pi; 
typedef pair<double,double> pd;
typedef pair<ll,ll> pl;

const int max_n = 1e5+7;
double arr[max_n];
double dp[max_n][2];

int main(){

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

    int t,n; cin >> t >> n;

    rep(i,1,t) cin >> arr[i];
    sort(arr+1,arr+1+t,greater<double>());

    double ans = 0;
    int akt = 0; dp[0][0] = 1;
    rep(i,1,t){
        //cout << "\ni: " << i << " arr: " << arr[i] << '\n';
        akt ^= 1;
        rep(j,0,2*i){
            dp[j][akt] = dp[j][akt^1]*(double(1)-arr[i]);
            if(j >= 2) dp[j][akt] += dp[j-2][akt^1]*arr[i];
            //cout << "j: " << j << " dp: " << dp[j][akt] << '\n';
        }
        double val = 0;
        rep(j,i+n,2*i) val += dp[j][akt];
        //cout << "i: " << i << " val: " << val << '\n';
        ans = max(ans,val);
    }

    cout << fixed << setprecision(7) << ans;

    return 0;
}

//g++ -O3 -static -Wall .cpp -std=c++17