Submission #3951098


Source Code Expand

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

    typedef long long ll;
    const ll MOD = 1e9+7;
    const int N = 3005;

    int n;
    double p[N],dp[N][N];

    int main()
    {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        cin>>n;
        for(int i=1;i<=n;i++)cin>>p[i];

        dp[0][0]=1.0;

        for(int i=1;i<=n;i++){
            for(int j=0;j<=i;j++){
                if(j)dp[i][j]=p[i]*dp[i-1][j-1]+(1.0-p[i])*(dp[i-1][j]);
                else dp[i][j]=(1-p[i])*dp[i-1][j];
            }
        }

        double ans=0.0;


        for(int i=1;i<=n;i++){
            if(i>n-i)ans+=dp[n][i];
        }

        cout<<fixed<<setprecision(8)<<ans;
        return 0;
    }

Submission Info

Submission Time
Task I - Coins
User Vasiljko
Language C++14 (GCC 5.4.1)
Score 0
Code Size 757 Byte
Status
Exec Time 34 ms
Memory 69120 KB

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 100 0_00, 0_01, 0_02, 1_00, 1_01, 1_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14, 1_15, 1_16, 1_17, 1_18, 1_19, 1_20, 1_21, 1_22, 1_23, 1_24, 1_25, 1_26, 1_27, 1_28, 1_29
Case Name Status Exec Time Memory
0_00 1 ms 256 KB
0_01 1 ms 256 KB
0_02 1 ms 256 KB
1_00 1 ms 256 KB
1_01 1 ms 256 KB
1_02 1 ms 256 KB
1_03 30 ms 69120 KB
1_04 34 ms 69120 KB
1_05 30 ms 69120 KB
1_06 34 ms 68736 KB
1_07 34 ms 68864 KB
1_08 33 ms 68224 KB
1_09 33 ms 68480 KB
1_10 33 ms 68224 KB
1_11 33 ms 68224 KB
1_12 33 ms 68224 KB
1_13 34 ms 68864 KB
1_14 33 ms 68224 KB
1_15 33 ms 68224 KB
1_16 33 ms 68608 KB
1_17 34 ms 68992 KB
1_18 33 ms 68224 KB
1_19 33 ms 68224 KB
1_20 33 ms 68224 KB
1_21 33 ms 68608 KB
1_22 33 ms 68608 KB
1_23 34 ms 68480 KB
1_24 33 ms 68352 KB
1_25 34 ms 68352 KB
1_26 33 ms 68224 KB
1_27 34 ms 68864 KB
1_28 33 ms 68224 KB
1_29 33 ms 68224 KB