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
54
#include<bits/stdc++.h>

using namespace std;

void solve(){
    int n, t;
    cin >> n >> t;
    vector<double> prop;
    for(int i = 0; i < n; i++){
        double a;
        cin >> a;
        prop.push_back(a);
    }
    sort(prop.begin(), prop.end());
    reverse(prop.begin(), prop.end());

    int lmt = (n-t)/2+2; 
    vector<double> arr(lmt);
    arr[0] = 1;
    double ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = min(i + 1, lmt-1); j > 0; j--){
            arr[j] = (prop[i] * arr[j]) + ((1-prop[i]) * arr[j-1]);
        }
        arr[0] = (prop[i] * arr[0]);
        double ans_tmp = 0;
        for(int j = 0; j <= min(i + 1, lmt-1); j++){
            if((i+1)-2*j < t){
                break;
            }
            ans_tmp += arr[j];
        }
        ans = max(ans, ans_tmp);
    }
    //cout.precision(7);
    cout << setprecision(8) << fixed;
    cout << ans << '\n';
    
  


}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    
    return 0;
}