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
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

// hloya template v26

// ░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░░░░░
// ░░░░░░█░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░█░░░░░
// ░░░░░░█░█░▀░░░░░▀░░▀░░░░█░█░░░░░
// ░░░░░░█░█░░░░░░░░▄▀▀▄░▀░█░█▄▀▀▄░
// █▀▀█▄░█░█░░▀░░░░░█░░░▀▄▄█▄▀░░░█░
// ▀▄▄░▀██░█▄░▀░░░▄▄▀░░░░░░░░░░░░▀▄
// ░░▀█▄▄█░█░░░░▄░░█░░░▄█░░░▄░▄█░░█
// ░░░░░▀█░▀▄▀░░░░░█░██░▄░░▄░░▄░███
// ░░░░░▄█▄░░▀▀▀▀▀▀▀▀▄░░▀▀▀▀▀▀▀░▄▀░
// ░░░░█░░▄█▀█▀▀█▀▀▀▀▀▀█▀▀█▀█▀▀█░░░
// ░░░░▀▀▀▀░░▀▀▀░░░░░░░░▀▀▀░░▀▀░░░░

#include <bits/stdc++.h>
using namespace std;

bool dbg = 0;

clock_t start_time = clock();
#define current_time                                                           \
  fixed << setprecision(6) << (ld)(clock() - start_time) / CLOCKS_PER_SEC

#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define sqr(x) ((x) * (x))

#define ull unsigned long long
#define ll long long
#define ld long double
#define pii pair<int, int>
#define umap unordered_map<int, int>

#define files1 freopen("input.txt", "r", stdin)
#define files2 freopen("output.txt", "w", stdout)
#define files                                                                  \
  files1;                                                                      \
  files2
#define fast_io                                                                \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0)

// #define endl '\n'
#define ln(i, n) " \n"[(i) == (n)-1]

void bad(string mes = "NO") {
  cout << mes;
  exit(0);
}
void bad(int mes) {
  cout << mes;
  exit(0);
}

template <typename T> string bin(T x, int st = 2) {
  string ans = "";
  while (x > 0) {
    ans += char('0' + x % st);
    x /= st;
  }
  reverse(ans.begin(), ans.end());
  return ans.empty() ? "0" : ans;
}

mt19937_64 mt_rand(228 // chrono::system_clock::now().time_since_epoch().count()
);

template <typename T1, typename T2> inline bool upmax(T1 &a, T2 b) {
  return (a < b ? (a = b, true) : false);
}
template <typename T1, typename T2> inline bool upmin(T1 &a, T2 b) {
  return (b < a ? (a = b, true) : false);
}

// inline int popcount(int x){
//     int count = 0;
//     __asm__ volatile("POPCNT %1, %0;":"=r"(count):"r"(x):);
//     return count;
// }

template <typename T> T input() {
  T ans = 0, m = 1;
  char c = ' ';

  while (!((c >= '0' && c <= '9') || c == '-')) {
    c = getchar();
  }

  if (c == '-')
    m = -1, c = getchar();
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + (c - '0'), c = getchar();
  }
  return ans * m;
}

template <typename T> T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}

template <typename T> void read(T &a) { a = input<T>(); }
template <typename T> void read(T &a, T &b) { read(a), read(b); }
template <typename T> void read(T &a, T &b, T &c) { read(a, b), read(c); }
template <typename T> void read(T &a, T &b, T &c, T &d) {
  read(a, b), read(c, d);
}

const int inf = 1e9 + 20;
const short short_inf = 3e4 + 20;
const long double eps = 1e-12;
const int maxn = (int)1500 + 3, base = 998244353;
const ll llinf = 2e18 + 5;
const int mod = 1e9 + 7;

double solveMoreOpt(int n, int k, vector<double> p) {
  std::vector<float> dp(n + 2, 0);
  std::vector<float> ndp(n + 2, 0);

  sort(all(p));
  reverse(all(p));

  double ans = 0;
  dp[0] = 1;

  for (int i = 0; i <= n; ++i) {
    double p_res = 0;
    int to = (i >= k ? (i - k) / 2 : -1);
    for (int lj = 0; lj <= i; lj++) {
      ndp[lj] += dp[lj] * p[i];
      ndp[lj + 1] += dp[lj] * (1 - p[i]);
      if (lj <= to) {
        p_res += dp[lj];
      }
    }
    if (p_res > ans) {
      ans = p_res;
    }

    swap(dp, ndp);
    fill(ndp.begin(), ndp.begin() + i + 1, 0);
  }

  return ans;
}

int main() {
  // files1;
  fast_io;

  int n, k;
  cin >> n >> k;
  vector<double> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }

  cout << fixed << setprecision(10) << solveMoreOpt(n, k, p) << endl;
  return 0;
}