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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
// {{{ file: egz.cpp | time: 16:36 12.03.2025
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define each(...)    for (auto& __VA_ARGS__)
#define rep(i, b, e) for (int i = (b); i <= (e); i++)
#define rev(i, b, e) for (int i = (e); i >= (b); i--)
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define tC template<class
#define $(x) #x<<'='<<(x)<<' '

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vpi = vector<pii>;
using vpl = vector<pll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
tC T, class C=greater<T>> using min_priority_queue = priority_queue<T,vector<T>,C>;
tC T> int sz(const T& a) { return (int)a.size(); }
tC T> bool amin(T& a, T b) { return b < a ? a = b, 1 : 0; }
tC T> bool amax(T& a, T b) { return b > a ? a = b, 1 : 0; }
const int oo = 1e9+1;
const ll OO = ll(1e18)+1;

auto now() { return chrono::high_resolution_clock::now().time_since_epoch().count(); }
mt19937 rnd(4488);
tC T> T rand(T lo, T hi) { return uniform_int_distribution<T>{lo,hi}(rnd); }

struct Debug {
#ifdef SPONGE
  tC T>Debug operator<<(const T& x) { cerr<<"\033[1;33m"<<x<<"\033[0m"; return *this; }
#else
  tC T>Debug operator<<(const T&) { return *this; }
#endif
} dbg;

namespace { void solve(); }
// }}}

int main()
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(7);
  cout.setf(ios::fixed,ios::floatfield);
  cerr.precision(15);
  cerr.setf(ios::fixed,ios::floatfield);
  //rnd.seed(now());
  int t=1;
  //cin>>t;
  rep(i,1,t){
    //cout<<"Case #"<<i<<": ";
    solve();
  }
}

namespace {

using F=long double;
using C=complex<F>;
using vf=vector<F>;

void fft(vector<C>& a) {
	int n = sz(a), L = 31 - __builtin_clz(n);
	static vector<C> R(2, 1);
	static vector<C> rt(2, 1);  // (^ 10% faster if double)
	for (static int k = 2; k < n; k *= 2) {
		R.resize(n); rt.resize(n);
		auto x = polar(1.0L, acos(-1.0L) / k);
		rep(i,k,2*k-1) rt[i] = R[i] = i&1 ? R[i/2] * x : R[i/2];
	}
	vi odw(n);
	rep(i,0,n-1) odw[i] = (odw[i / 2] | (i & 1) << L) / 2;
	rep(i,0,n-1) if (i < odw[i]) swap(a[i], a[odw[i]]);
	for (int k = 1; k < n; k *= 2)
		for (int i = 0; i < n; i += 2 * k) rep(j,0,k-1) {
			// C z = rt[j+k] * a[i+j+k]; // (25% faster if hand-rolled)  /// include-line
			auto x = (F *)&rt[j+k], y = (F *)&a[i+j+k];        /// exclude-line
			C z(x[0]*y[0] - x[1]*y[1], x[0]*y[1] + x[1]*y[0]);           /// exclude-line
			a[i + j + k] = a[i + j] - z;
			a[i + j] += z;
		}
}
vf conv(const vf& a, const vf& b) {
	if (a.empty() || b.empty()) return {};
	vf res(sz(a) + sz(b) - 1);
	int L = 32 - __builtin_clz(sz(res)), n = 1 << L;
	vector<C> in(n), out(n);
	copy(all(a), begin(in));
	rep(i,0,sz(b)-1) in[i].imag(b[i]);
	fft(in);
	for (C& x : in) x *= x;
	rep(i,0,n-1) out[i] = in[-i & (n - 1)] - conj(in[i]);
	fft(out);
	rep(i,0,sz(res)-1) res[i] = imag(out[i]) / (4 * n);
	return res;
}

vf rekurencja(vf p)
{
  int n=sz(p);
  //if(n==0) return { 1.0 };
  //else if(n==1) return { 1-p[0], p[0] };
  if(n<=300){
    vf w(n+1);
    w[0]=1;
    rep(i,0,n-1){
      rev(j,1,i+1) w[j]=p[i]*w[j-1]+(1-p[i])*w[j];
      w[0]=(1-p[i])*w[0];
    }
    return w;
  }
  else{
    int k=n/2;
    vf p1(k),p2(n-k);
    rep(i,0,k-1) p1[i]=p[i];
    rep(i,k,n-1) p2[i-k]=p[i];
    vf w1=rekurencja(p1);
    vf w2=rekurencja(p2);
    return conv(w1,w2);
  }
}

/*
F funkcja(vf& p,int t,int x)
{
  vf u(x);
  rep(i,0,x-1) u[i]=p[i];
  rep(i,1,x-1) swap(u[i],u[rand(0,i)]);
  vf w=rekurencja(u);
  F suma=0;
  rep(i,(x+t+1)/2,x) suma+=w[i];
  return suma;
}

F wyszukaj(vf p,vi v,int t)
{
  int poc=0,kon=sz(v)-1;
  while(poc<=kon && v[poc]<t) poc++;
  while(kon-poc>=3){
    int m1=poc+(kon-poc)/3;
    int m2=kon-(kon-poc)/3;
    F out1=funkcja(p,t,v[m1]);
    F out2=funkcja(p,t,v[m2]);
    //cout<<$(poc)<<$(kon)<<$(out1)<<$(out2)<<endl;
    //cout.flush();
    //if(abs(out2-out1) <= 1e-9) return out1;
    if(out1>out2) kon=m2; else poc=m1;
  }
  F odp=0;
  rep(i,poc,kon) amax(odp,funkcja(p,t,v[i]));
  return odp;
}
*/

F funkcja_para(vf& p,int t,int x1,int x2,F& out1,F& out2)
{
  vf u(x1);
  rep(i,0,x1-1) u[i]=p[i];
  rep(i,1,x1-1) swap(u[i],u[rand(0,i)]);
  vf w=rekurencja(u);
  out1=0;
  rep(i,(x1+t+1)/2,x1) out1+=w[i];
  F maks_out=out1;
  rep(x,x1+1,x2){
    w.pb(p[x-1]*w[x-1]);
    rev(i,1,x-1) w[i]=w[i-1]*p[x-1]+w[i]*(1-p[x-1]);
    w[0]=w[0]*(1-p[x-1]);
    F out_x=0;
    rep(i,(x+t+1)/2,x) out_x+=w[i];
    amax(maks_out,out_x);
  }
  out2=0;
  rep(i,(x2+t+1)/2,x2) out2+=w[i];
  amax(maks_out,out2);
  return maks_out;
}

F wyszukaj(vf p,vi v,int t)
{
  int poc=0,kon=sz(v)-1;
  while(poc<=kon && v[poc]<t) poc++;
  if(poc>kon) return 0.0;
  while(kon-poc>=300){
    int m1=(poc+kon)/2;
    int m2=m1+1;
    F out1,out2;
    funkcja_para(p,t,v[m1],v[m2],out1,out2);
    if(out1>out2) kon=m2; else poc=m1;
  }
  /*
  F odp=0;
  rep(i,poc,kon) amax(odp,funkcja(p,t,v[i]));
  return odp;
  */
  F out1,out2;
  return funkcja_para(p,t,v[poc],v[kon],out1,out2);
}

void solve()
{
  int n,t;
  cin>>n>>t;
  
  vf p(n);
  rep(i,0,n-1) cin>>p[i];
  sort(all(p));
  reverse(all(p));

  vf mu(n+1),chce(n+1),chernoff(n+1);
  rep(x,1,n){
    mu[x]=mu[x-1]+p[x-1];
    chce[x]=(t+x+1)/2;
    if(mu[x]<chce[x]){
      F delta=chce[x]/mu[x]-1;
      chernoff[x]=-delta*delta/(2+delta)*mu[x];
    }
  }

  vi even,odd;
  rep(i,1,n) if(chernoff[i]>=-17){
    if(i%2==1) odd.pb(i);
    else even.pb(i);
  }

  F odp1=wyszukaj(p,even,t);
  F odp2=wyszukaj(p,odd,t);
  F odp=max(odp1,odp2);
  cout<<odp<<endl;
}

}