Language: C++

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

#define     all(x) x.begin(),x.end()
#define     ff first
#define     ss second
#define     ll long long
#define     ld long double
#define     pb push_back
#define     endl "\n"
#define     MOD 1000000007
#define     INF 1e18
#define     mod 998244353
#define     REP(i,n) for(ll i=0;i<(n);i++)
#define     FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define     FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define     BLOCK 555
mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());

typedef     vector <ll> vll;
typedef     vector <pair<ll,ll>> vp;
typedef     vector<vector<ll> >vvll;


/*      author:- Indrajit Sen
        Institution:- Jalpaiguri Government Engineering College
        id:- @Is97, @indra1997
                                                                */
                                                                

                                                            


// log(y) power calculation
ll power_mod(ll x, ll y, ll m){
    ll arr = 1;
    x%=m;
    while(y){
        if(y&1){
            arr=(arr*x)%m;
        }
        y>>=1;
        x=(x*x)%m;
    }
    return arr;
}

ll power(ll x, ll y){
    ll arr = 1;
    while(y){
        if(y&1){
            arr*=x;
        }
        y>>=1;
        x = x*x;
    }
    return arr;
}


ll mod_inv(ll x,ll m){
    return power_mod(x,m-2,m);
}

int randomGenerator(int limit){ 
    
        random_device rd; 
        mt19937 gen(rd()); 
        uniform_int_distribution<> dis(1, limit);

    return dis(gen);
}

// customized hash function for lowering the collision in UNORDERED_MAP
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
       
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
 

bool comp(const pair<ll,pair<ll,ll>> &a, const pair<ll,pair<ll,ll>> &b) { 
    if(a.ff == b.ff){

        return (a.second < b.second); 
    }
    return (a.ff < b.ff); 
} 

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

bool isPalindrome(string s){
    bool flag = true;
    for(int i=0;i<s.length()/2;i++){
        if(s[i]!=s[s.length()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}

ld dp[3001][3001], probablity[3001];
ll n;
ld recur(ll ind, ll head){
    if(ind == n){
        if(head>=((n+1)/2)){
            return 1.0;
        }
        else{
            return 0.0;
        }
    }
    ld &ans=dp[ind][head];
    if(ans>=1.0 and ans<=0.0){
        return ans;
    }
    ans = recur(ind + 1, head + 1)*probablity[ind] + recur(ind + 1, head)*(1.0-probablity[ind]);
    return ans;
}


void solve(){
    cin>>n;
    memset(dp,-1.0,sizeof(dp));
    REP(i,n){
        cin>>probablity[i];
    }
    ld ans = recur(0, 0);
    cout<<fixed<<setprecision(9)<<ans<<endl;

}


int main(){
    
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

    solve();

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

#define     all(x) x.begin(),x.end()
#define     ff first
#define     ss second
#define     ll long long
#define     ld long double
#define     pb push_back
#define     endl "\n"
#define     MOD 1000000007
#define     INF 1e18
#define     mod 998244353
#define     REP(i,n) for(ll i=0;i<(n);i++)
#define     FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define     FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define     BLOCK 555
mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());

typedef     vector <ll> vll;
typedef     vector <pair<ll,ll>> vp;
typedef     vector<vector<ll> >vvll;


/*      author:- Indrajit Sen
        Institution:- Jalpaiguri Government Engineering College
        id:- @Is97, @indra1997
                                                                */
                                                                

                                                            


// log(y) power calculation
ll power_mod(ll x, ll y, ll m){
    ll arr = 1;
    x%=m;
    while(y){
        if(y&1){
            arr=(arr*x)%m;
        }
        y>>=1;
        x=(x*x)%m;
    }
    return arr;
}

ll power(ll x, ll y){
    ll arr = 1;
    while(y){
        if(y&1){
            arr*=x;
        }
        y>>=1;
        x = x*x;
    }
    return arr;
}


ll mod_inv(ll x,ll m){
    return power_mod(x,m-2,m);
}

int randomGenerator(int limit){ 
    
        random_device rd; 
        mt19937 gen(rd()); 
        uniform_int_distribution<> dis(1, limit);

    return dis(gen);
}

// customized hash function for lowering the collision in UNORDERED_MAP
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
       
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
 

bool comp(const pair<ll,pair<ll,ll>> &a, const pair<ll,pair<ll,ll>> &b) { 
    if(a.ff == b.ff){

        return (a.second < b.second); 
    }
    return (a.ff < b.ff); 
} 

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

bool isPalindrome(string s){
    bool flag = true;
    for(int i=0;i<s.length()/2;i++){
        if(s[i]!=s[s.length()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}

ld dp[3001][3001], probablity[3001];
ll n;
ld recur(ll ind, ll head){
    if(ind == n){
        if(head>=((n+1)/2)){
            return 1.0;
        }
        else{
            return 0.0;
        }
    }
    ld &ans=dp[ind][head];
    if(ans>=1.0 and ans<=0.0){
        return ans;
    }
    ans = recur(ind + 1, head + 1)*probablity[ind] + recur(ind + 1, head)*(1.0-probablity[ind]);
    return ans;
}


void solve(){
    cin>>n;
    memset(dp,-1.0,sizeof(dp));
    REP(i,n){
        cin>>probablity[i];
    }
    ld ans = recur(0, 0);
    cout<<fixed<<setprecision(9)<<ans<<endl;

}


int main(){
    
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

    solve();

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

#define     all(x) x.begin(),x.end()
#define     ff first
#define     ss second
#define     ll long long
#define     ld long double
#define     pb push_back
#define     endl "\n"
#define     MOD 1000000007
#define     INF 1e18
#define     mod 998244353
#define     REP(i,n) for(ll i=0;i<(n);i++)
#define     FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define     FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define     BLOCK 555
mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());

typedef     vector <ll> vll;
typedef     vector <pair<ll,ll>> vp;
typedef     vector<vector<ll> >vvll;


/*      author:- Indrajit Sen
        Institution:- Jalpaiguri Government Engineering College
        id:- @Is97, @indra1997
                                                                */
                                                                

                                                            


// log(y) power calculation
ll power_mod(ll x, ll y, ll m){
    ll arr = 1;
    x%=m;
    while(y){
        if(y&1){
            arr=(arr*x)%m;
        }
        y>>=1;
        x=(x*x)%m;
    }
    return arr;
}

ll power(ll x, ll y){
    ll arr = 1;
    while(y){
        if(y&1){
            arr*=x;
        }
        y>>=1;
        x = x*x;
    }
    return arr;
}


ll mod_inv(ll x,ll m){
    return power_mod(x,m-2,m);
}

int randomGenerator(int limit){ 
    
        random_device rd; 
        mt19937 gen(rd()); 
        uniform_int_distribution<> dis(1, limit);

    return dis(gen);
}

// customized hash function for lowering the collision in UNORDERED_MAP
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
       
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
 

bool comp(const pair<ll,pair<ll,ll>> &a, const pair<ll,pair<ll,ll>> &b) { 
    if(a.ff == b.ff){

        return (a.second < b.second); 
    }
    return (a.ff < b.ff); 
} 

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

bool isPalindrome(string s){
    bool flag = true;
    for(int i=0;i<s.length()/2;i++){
        if(s[i]!=s[s.length()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}

ld dp[3001][3001], probablity[3001];
ll n;
ld recur(ll ind, ll head){
    if(ind == n){
        if(head>=((n+1)/2)){
            return 1.0;
        }
        else{
            return 0.0;
        }
    }
    ld &ans=dp[ind][head];
    if(ans>=1.0 and ans<=0.0){
        return ans;
    }
    ans = recur(ind + 1, head + 1)*probablity[ind] + recur(ind + 1, head)*(1.0-probablity[ind]);
    return ans;
}


void solve(){
    cin>>n;
    memset(dp,-1.0,sizeof(dp));
    REP(i,n){
        cin>>probablity[i];
    }
    ld ans = recur(0, 0);
    cout<<fixed<<setprecision(9)<<ans<<endl;

}


int main(){
    
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

    solve();

    return 0;
}

Compiler output:
a.cc:161:2: error: stray '#' in program
  161 | }#include <bits/stdc++.h>
      |  ^
a.cc:321:2: error: stray '#' in program
  321 | }#include <bits/stdc++.h>
      |  ^
a.cc:161:3: error: 'include' does not name a type
  161 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:178:13: error: redefinition of 'std::mt19937 rng'
  178 | mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());
      |             ^~~
a.cc:18:13: note: 'std::mt19937 rng' previously declared here
   18 | mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());
      |             ^~~
a.cc:195:4: error: redefinition of 'long long int power_mod(long long int, long long int, long long int)'
  195 | ll power_mod(ll x, ll y, ll m){
      |    ^~~~~~~~~
a.cc:35:4: note: 'long long int power_mod(long long int, long long int, long long int)' previously defined here
   35 | ll power_mod(ll x, ll y, ll m){
      |    ^~~~~~~~~
a.cc:208:4: error: redefinition of 'long long int power(long long int, long long int)'
  208 | ll power(ll x, ll y){
      |    ^~~~~
a.cc:48:4: note: 'long long int power(long long int, long long int)' previously defined here
   48 | ll power(ll x, ll y){
      |    ^~~~~
a.cc:221:4: error: redefinition of 'long long int mod_inv(long long int, long long int)'
  221 | ll mod_inv(ll x,ll m){
      |    ^~~~~~~
a.cc:61:4: note: 'long long int mod_inv(long long int, long long int)' previously defined here
   61 | ll mod_inv(ll x,ll m){
      |    ^~~~~~~
a.cc:225:5: error: redefinition of 'int randomGenerator(int)'
  225 | int randomGenerator(int limit){
      |     ^~~~~~~~~~~~~~~
a.cc:65:5: note: 'int randomGenerator(int)' previously defined here
   65 | int randomGenerator(int limit){
      |     ^~~~~~~~~~~~~~~
a.cc:235:8: error: redefinition of 'struct custom_hash'
  235 | struct custom_hash {
      |        ^~~~~~~~~~~
a.cc:75:8: note: previous definition of 'struct custom_hash'
   75 | struct custom_hash {
      |        ^~~~~~~~~~~
a.cc:252:6: error: redefinition of 'bool comp(const std::pair<long long int, std::pair<long long int, long long int> >&, const std::pair<long long int, std::pair<long long int, long long int> >&)'
  252 | bool comp(const pair<ll,pair<ll,ll>> &a, const pair<ll,pair<ll,ll>> &b) {
      |      ^~~~
a.cc:92:6: note: 'bool comp(const std::pair<long long int, std::pair<long long int, long long int> >&, const std::pair<long long int, std::pair<long long int, long long int> >&)' previously defined here
   92 | bool comp(const pair<ll,pair<ll,ll>> &a, const pair<ll,pair<ll,ll>> &b) {
      |      ^~~~
a.cc:260:8: error: redefinition of 'struct hash_pair'
  260 | struct hash_pair {
      |        ^~~~~~~~~
a.cc:100:8: note: previous definition of 'struct hash_pair'
  100 | struct hash_pair {
      |        ^~~~~~~~~
a.cc:270:6: error: redefinition of 'bool isPalindrome(std::string)'
  270 | bool isPalindrome(string s){
      |      ^~~~~~~~~~~~
a.cc:110:6: note: 'bool isPalindrome(std::string)' previously defined here
  110 | bool isPalindrome(string s){
      |      ^~~~~~~~~~~~
a.cc:281:4: error: redefinition of 'long double dp [3001][3001]'
  281 | ld dp[3001][3001], probablity[3001];
      |    ^~
a.cc:121:4: note: 'long double dp [3001][3001]' previously declared here
  121 | ld dp[3001][3001], probablity[3001];
      |    ^~
a.cc:281:20: error: redefinition of 'long double probablity [3001]'
  281 | ld dp[3001][3001], probablity[3001];
      |                    ^~~~~~~~~~
a.cc:121:20: note: 'long double probablity [3001]' previously declared here
  121 | ld dp[3001][3001], probablity[3001];
      |                    ^~~~~~~~~~
a.cc:282:4: error: redefinition of 'long long int n'
  282 | ll n;
      |    ^
a.cc:122:4: note: 'long long int n' previously declared here
  122 | ll n;
      |    ^
a.cc:283:4: error: redefinition of 'long double recur(long long int, long long int)'
  283 | ld recur(ll ind, ll head){
      |    ^~~~~
a.cc:123:4: note: 'long double recur(long long int, long long int)' previously defined here
  123 | ld recur(ll ind, ll head){
      |    ^~~~~
a.cc:301:6: error: redefinition of 'void solve()'
  301 | void solve(){
      |      ^~~~~
a.cc:141:6: note: 'void solve()' previously defined here
  141 | void solve(){
      |      ^~~~~
a.cc:313:5: error: redefinition of 'int main()'
  313 | int main(){
      |     ^~~~
a.cc:153:5: note: 'int main()' previously defined here
  153 | int main(){
      |     ^~~~
a.cc:321:3: error: 'include' does not name a type
  321 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:338:13: error: redefinition of 'std::mt19937 rng'
  338 | mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());
      |             ^~~
a.cc:18:13: note: 'std::mt19937 rng' previously declared here
   18 | mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());
      |             ^~~
a.cc:355:4: error: redefinition of 'long long int power_mod(long long int, long long int, long long int)'
  355 | ll power_mod(ll x, ll y, ll m){
      |    ^~~~~~~~~
a.cc:35:4: note: 'long long int power_mod(long long int, long long int, long long int)' previously defined here
   35 | ll power_mod(ll x, ll y, ll m){
      |    ^~~~~~~~~
a.cc:368:4: error: redefinition of 'long long int power(long long int, long long int)'
  368 | ll power(ll x, ll y){
      |    ^~~~~
a.cc:48:4: note: 'long long int power(long long int, long long int)' previously defined here
   48 | ll power(ll x, ll y){
      |    ^~~~~
a.cc:381:4: error: redefinition of 'long long int mod_inv(long long int, long long int)'
  381 | ll mod_inv(ll x,ll m){
      |    ^~~~~~~
a.cc:61:4: note: 'long long int mod_inv(long long int, long long int)' previously defined here
   61 | ll mod_inv(ll x,ll m){
      |    ^~~~~~~
a.cc:385:5: error: redefinition of 'int randomGenerator(int)'
  385 | int randomGenerator(int limit){
      |     ^~~~~~~~~~~~~~~
a.cc:65:5: note: 'int randomGenerator(int)' previously defined here
   65 | int randomGenerator(int limit){
      |     ^~~~~~~~~~~~~~~
a.cc:395:8: error: redefinition of 'struct custom_hash'
  395 | struct custom_hash {
      |        ^~~~~~~~~~~
a.cc:75:8: note: previous definition of 'struct custom_hash'
   75 | struct custom_hash {
      |        ^~~~~~~~~~~
a.cc:412:6: error: redefinition of 'bool comp(const std::pair<long long int, std::pair<long long int, long long int> >&, const std::pair<long long int, std::pair<long long int, long long int> >&)'
  412 | bool comp(const pair<ll,pair<ll,ll>> &a, const pair<ll,pair<ll,ll>> &b) {
      |      ^~~~
a.cc:92:6: note: 'bool comp(const std::pair<long long int, std::pair<long long int, long long int> >&, const std::pair<long long int, std::pair<long long int, long long int> >&)' previously defined here
   92 | bool comp(const pair<ll,pair<ll,ll>> &a, const pair<ll,pair<ll,ll>> &b) {
      |      ^~~~
a.cc:420:8: error: redefinition of 'struct hash_pair'
  420 | struct hash_pair {
      |        ^~~~~~~~~
a.cc:100:8: note: previous definition of 'struct hash_pair'
  100 | struct hash_pair {
      |        ^~~~~~~~~
a.cc:430:6: error: redefinition of 'bool isPalindrome(std::string)'
  430 | bool isPalindrome(string s){
      |      ^~~~~~~~~~~~
a.cc:110:6: note: 'bool isPalindrome(std::string)' previously defined here
  110 | bool isPalindrome(string s){
      |      ^~~~~~~~~~~~
a.cc:441:4: error: redefinition of 'long double dp [3001][3001]'
  441 | ld dp[3001][3001], probablity[3001];
      |    ^~
a.cc:121:4: note: 'long double dp [3001][3001]' previously declared here
  121 | ld dp[3001][3001], probablity[3001];
      |    ^~
a.cc:441:20: error: redefinition of 'long double probablity [3001]'
  441 | ld dp[3001][3001], probablity[3001];
      |                    ^~~~~~~~~~
a.cc:121:20: note: 'long double probablity [3001]' previously declared here
  121 | ld dp[3001][3001], probablity[3001];
      |                    ^~~~~~~~~~
a.cc:442:4: error: redefinition of 'long long int n'
  442 | ll n;
      |    ^
a.cc:122:4: note: 'long long int n' previously declared here
  122 | ll n;
      |    ^
a.cc:443:4: error: redefinition of 'long double recur(long long int, long long int)'
  443 | ld recur(ll ind, ll head){
      |    ^~~~~
a.cc:123:4: note: 'long double recur(long long int, long long int)' previously defined here
  123 | ld recur(ll ind, ll head){
      |    ^~~~~
a.cc:461:6: error: redefinition of 'void solve()'
  461 | void solve(){
      |      ^~~~~
a.cc:141:6: note: 'void solve()' previously defined here
  141 | void solve(){
      |      ^~~~~
a.cc:473:5: error: redefinition of 'int main()'
  473 | int main(){
      |     ^~~~
a.cc:153:5: note: 'int main()' previously defined here
  153 | int main(){
      |     ^~~~