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;

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...) (void)0
#endif

namespace R = ranges;
namespace V = views;
auto ra(auto x, auto y) { return R::iota_view(x, y); }
auto rae(auto x, auto y) { return ra(x, y + 1); }
using i64 = int64_t;

void solve() {
  int n, t;
  cin >> n >> t;
  vector<double> p(n + 1);
  for (auto i : rae(1, n)) {
    cin >> p[i];
  }
  sort(begin(p) + 1, end(p));
  reverse(begin(p) + 1, end(p));

  vector dp(n + 1, vector<double>(n + 1));
  dp[0][0] = 1;
  for (auto i : rae(1, n)) {
    dp[i][0] = (1 - p[i]) * dp[i - 1][0];
    for (auto j : rae(1, n)) {
      dp[i][j] = p[i] * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j];
    }
  }

  double ans = 0;
  for (auto i : rae(t, n)) {
    // x * 1 + (i - x) * -1 = t => x = i - (i - t) / 2
    int from = i - (i - t) / 2;
    ans = max(ans, accumulate(begin(dp[i]) + from, end(dp[i]), double(0)));
  }
  cout << fixed << setprecision(20) << ans << endl;
}

int32_t main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  for (auto tc_n : ra(0, t)) {
    debug(tc_n);
    solve();
    cout.flush();
  }
}