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

#define rep(a,b,c) for(auto a = (b); a != (c); a++)
#define repD(a,b,c) for(auto a = (b); a != (c); a--)
#define repIn(a, b) for(auto& a : (b))
#define repIn2(a, b, c) for(auto& [a, b] : (c))

constexpr bool dbg = 0;
#define DEBUG if constexpr(dbg)
#define DC DEBUG std::cerr
#define eol std::endl

#define ll long long
#define pb push_back
#define ld long double

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n, k;
    n = 5e4, k = 0;
    cin >> n >> k;
    vector<ld> arr(n);

   //  mt19937 rnd(2137);
   //  rep(i, 0, n) arr[i] = (ld)1 / (ld)(rnd() % 1000);

    rep(i, 0, n) cin >> arr[i];
    ranges::sort(arr, ranges::greater());
    vector<vector<ld>> dp(2, vector<ld>(n + 1, 0));
    dp[0][0] = 1;
    ld ans = 0;
    rep(i, 0, n) {
        rep(j, 0, i + 2) dp[1 ^ i & 1][j] = dp[i & 1][j] * (1 - arr[i]) + (j == 0 ? 0 : dp[i & 1][j - 1] * arr[i]);
        DEBUG {
            DC << "dp[" << i + 1 << "] = ";
            rep(j, 0, i + 2) DC << dp[1 ^ i & 1][j] << (2 * j - i - 1 < k && 2 * j + 1 - i >= k ? "    " : " ");
            // 2 * j - i - 1 >= k
            // 2 * j >= k + i + 1
            // j >= (k + i + 1) / 2
            DC << eol;
        }
        if(i + 1 < k) continue;
        ld myAns = 0;
        rep(j, (k + i + 2) / 2, i + 2) myAns += dp[1 ^ i & 1][j];
        DEBUG rep(j, (k + i + 2) / 2, i + 2) DC << "  " << j << "  " << (2 * j - 1 - i >= k) << eol;
        ans = max(ans, myAns);
    }
    cout << setprecision(18) << fixed << ans << '\n';
}