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

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int a, b;
	double tmp, tmp2, tmp3;
	cin >> a >> b;
	vector <double> c;
	vector <double> pc2;
	vector <double> pc;
	for(int i = 0; i < a; i++){
		cin >> tmp;
		c.push_back(tmp);
		pc2.push_back(0);
		pc2.push_back(0);
		pc.push_back(0);
		pc.push_back(0);
	}
	pc.push_back(0);
	pc2.push_back(0);
	pc[a] = 1;
	pc2[a] = 1;
	sort(c.begin(), c.end());
	tmp2 = tmp = 0;
	for(int i = 0; i < a; i++){
		tmp3 = tmp2;
		tmp2 = tmp;
		tmp = 0;
		for(int j = a - i - 1; j <= a + i + 1; j++) pc[j] = pc2[j - 1] * c[a - i - 1] + pc2[j + 1] * (1 - c[a - i - 1]);
		for(int j = a - i - 1; j <= a + i + 1; j++) pc2[j] = pc[j];
		for(int j = a + b; j <= a * 2; j++) tmp += pc[j];
		if(tmp < tmp3) break;
	}
	cout << max(tmp2, tmp3);
	return 0;
}