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
// Arti1990, II UWr

#include <bits/stdc++.h>

#define forr(i, n)                  for(int i=0; i<n; i++)
#define FOREACH(iter, coll)         for(auto iter = coll.begin(); iter != coll.end(); ++iter)
#define FOREACHR(iter, coll)        for(auto iter = coll.rbegin(); iter != coll.rend(); ++iter)
#define lbound(P,K,FUN)             ({auto SSS=P, PPP = P-1, KKK=(K)+1; while(PPP+1!=KKK) {SSS = (PPP+(KKK-PPP)/2); if(FUN(SSS)) KKK = SSS; else PPP = SSS;} PPP;})
#define testy()                     int _tests; cin>>_tests; FOR(_test, 1, _tests)
#define CLEAR(tab)                  memset(tab, 0, sizeof(tab))
#define CONTAIN(el, coll)           (coll.find(el) != coll.end())
#define FOR(i, a, b)                for(int i=a; i<=b; i++)
#define FORD(i, a, b)               for(int i=a; i>=b; i--)
#define MP                          make_pair
#define PB                          push_back
#define ff                          first
#define ss                          second
#define deb(X)                      X;
#define SIZE(coll) 					((int)coll.size())
#define ld long double
#define BLOK 5000 // 5 // 700

#define M 1000000007
#define INF 1000000007LL

using namespace std;


/************************ FFT START *************** */
/*       wziąłem z cp-algorithms                    */

using cd = complex<ld>;
const ld PI = acos(-1);

void fft(vector<cd> & a, bool invert) {
    int n = a.size();
    if (n == 1)
        return;

    vector<cd> a0(n / 2), a1(n / 2);
    for (int i = 0; 2 * i < n; i++) {
        a0[i] = a[2*i];
        a1[i] = a[2*i+1];
    }
    fft(a0, invert);
    fft(a1, invert);

    ld ang = 2 * PI / n * (invert ? -1 : 1);
    cd w(1), wn(cos(ang), sin(ang));
    for (int i = 0; 2 * i < n; i++) {
        a[i] = a0[i] + w * a1[i];
        a[i + n/2] = a0[i] - w * a1[i];
        if (invert) {
            a[i] /= 2;
            a[i + n/2] /= 2;
        }
        w *= wn;
    }
}

vector<ld> multiply(vector<ld> const& a, vector<ld> const& b) {
    vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
    int n = 1;
    while (n < a.size() + b.size()) 
        n <<= 1;
    fa.resize(n);
    fb.resize(n);

    fft(fa, false);
    fft(fb, false);
    for (int i = 0; i < n; i++)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<ld> result(n);
    for (int i = 0; i < n; i++)
        result[i] = fa[i].real();
    return result;
}

/************************ FFT KONIEC *************** */



int n, t, last = 0, s_pos;
long double p[100007], dp[100007], s[100007];
vector <ld> d0({1});

void przelicz_wiersz(int i)
{
    //FORD(j, i, 1)
    //    dp[j] = dp[j] * (1-p[i]) + dp[j-1] * p[i];
    //dp[0] = dp[0] * (1-p[i]);

    if(i % BLOK == 0)
    {
        vector<ld> v(BLOK+1, 0);
        v[0] = 1;
        FOR(i2, 1, BLOK)
        {   
            FORD(j, i2, 1)
                v[j] = v[j] * (1-p[i-BLOK+i2]) + v[j-1] * p[i-BLOK+i2];
            v[0] = v[0] * (1-p[i-BLOK+i2]);
        }
        //for(auto el : v)
        //    cout << el << ' ';
        //cout << '\n';
        auto d = multiply(d0, v);
        d0.resize(i+1);
        forr(j, i+1)
        {
            d0[j] = d[j];
            dp[j] = d[j];
        }
        last = i;
    }
    else
    {
        int ile_jeszcze = BLOK - (i-last) + 3;
        FORD(j, min(i, s_pos+ile_jeszcze/2), max(1, s_pos-ile_jeszcze))
            dp[j] = dp[j] * (1-p[i]) + dp[j-1] * p[i];
        dp[0] = dp[0] * (1-p[i]);
    }
    /*
    vector <ld> v({1-p[i], p[i]});
    auto d = multiply(d0, v);
    //for(auto el : d)
    //    cout << el << ' ';
    //cout << '\n';
    d0.resize(i+1);
    forr(j, i+1)
    {
        d0[j] = d[j];
        dp[j] = d[j];
    }*/
}

int solve()
{
    cin >> n >> t;
    FOR(i, 1, n)
        cin >> p[i];
    sort(p+1, p+n+1, greater<ld>());
    //FOR(i, 1, n)
    //    cout << p[i] << '\n';

    dp[0] = 1;

    ld res = 0;
    ld sum = 0;
    s_pos = (t+1)/2;

    FOR(i, 1, n)
    {
        sum += dp[s_pos-1] * p[i];

        przelicz_wiersz(i);

        if(s_pos < (t+i+1)/2)
        {
            sum -= dp[s_pos];
            s_pos++;
        }

        res = max(res, sum);
    }

    cout << res << '\n';

    return 0;
}


int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cout << setprecision(7) << fixed;

    solve();

    return 0;
}