Problem:


Score : 100 points

Problem Statement

Let N be a positive odd number.

There are N coins, numbered 1, 2, \ldots, N.
For each i (1 \leq i \leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i.

Taro has tossed all the N coins.
Find the probability of having more heads than tails.

Constraints

N is an odd number.

1 \leq N \leq 2999

p_i is a real number and has two decimal places.

0 < p_i < 1

Input

Input is given from Standard Input in the following format:

N
p_1 p_2 \ldots p_N

Output

Print the probability of having more heads than tails.
The output is considered correct when the absolute error is not greater than 10^{-9}.

Sample Input 1

3
0.30 0.60 0.80

Sample Output 1

0.612

The probability of each case where we have more heads than tails is as follows:

The probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Head) is 0.3 × 0.6 × 0.8 = 0.144;

The probability of having (Coin 1, Coin 2, Coin 3) = (Tail, Head, Head) is 0.7 × 0.6 × 0.8 = 0.336;

The probability of having (Coin 1, Coin 2, Coin 3) = (Head, Tail, Head) is 0.3 × 0.4 × 0.8 = 0.096;

The probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Tail) is 0.3 × 0.6 × 0.2 = 0.036.

Thus, the probability of having more heads than tails is 0.144 + 0.336 + 0.096 + 0.036 = 0.612.

Sample Input 2

1
0.50

Sample Output 2

0.5

Outputs such as 0.500, 0.500000001 and 0.499999999 are also considered correct.

Sample Input 3

5
0.42 0.01 0.42 0.99 0.42

Sample Output 3

0.3821815872



Sample input:
3
0.30 0.60 0.80


Sample output:
0.612

Submission status: Runtime Error

Solution code:
n = int(input())

heads = list(map(float, input().split()))
# n = 2999
# heads = [0.75, 0.73, 0.61, 0.77, 0.2, 0.34, 0.56, 0.2, 0.08, 0.43, 0.26, 0.09, 0.73, 0.38, 0.19, 0.1, 0.57, 0.85, 0.25, 0.38, 0.95, 0.49, 0.06, 0.66, 0.8, 0.83, 0.5, 0.44, 0.77, 0.03, 0.2, 0.69, 0.83, 0.81, 0.23, 0.56, 0.7, 0.59, 0.58, 0.04, 0.26, 0.63, 0.18, 0.95, 0.5, 0.31, 0.23, 0.22, 0.8, 0.08, 0.13, 0.2, 0.94, 0.86, 0.91, 0.43, 0.44, 0.89, 0.94, 0.05, 0.72, 0.06, 0.94, 0.71, 0.74, 0.31, 0.55, 0.31, 0.48, 0.22, 0.62, 0.91, 0.43, 0.45, 0.73, 0.41, 0.67, 0.32, 0.74, 0.59, 0.11, 0.21, 0.18, 0.57, 0.41, 0.58, 0.24, 0.04, 0.45, 0.34, 0.37, 0.76, 0.22, 0.97, 0.87, 0.57, 0.13, 0.1, 0.52, 0.65, 0.22, 0.31, 0.83, 0.42, 0.31, 0.78, 0.26, 0.84, 0.29, 0.23, 0.78, 0.03, 0.27, 0.19, 0.16, 0.53, 0.69, 0.8, 0.68, 0.71, 0.37, 0.5, 0.45, 0.38, 0.9, 0.79, 0.46, 0.8, 0.88, 0.64, 0.98, 0.2, 0.96, 0.81, 0.93, 0.59, 0.57, 0.99, 0.91, 0.69, 0.98, 0.6, 0.83, 0.62, 0.75, 0.01, 0.18, 0.22, 0.8, 0.35, 0.05, 0.74, 0.91, 0.17, 0.06, 0.89, 0.54, 0.05, 0.82, 0.1, 0.39, 0.31, 0.87, 0.48, 0.26, 0.26, 0.31, 0.25, 0.64, 0.5, 0.84, 0.69, 0.03, 0.3, 0.94, 0.04, 0.01, 0.13, 0.88, 0.33, 0.21, 0.67, 0.98, 0.12, 0.96, 0.4, 0.59, 0.97, 0.81, 0.27, 0.97, 0.33, 0.81, 0.35, 0.83, 0.6, 0.34, 0.39, 0.12, 0.88, 0.21, 0.45, 0.99, 0.1, 0.14, 0.23, 0.59, 0.61, 0.11, 0.96, 0.71, 0.31, 0.08, 0.44, 0.68, 0.66, 0.76, 0.9, 0.52, 0.84, 0.31, 0.27, 0.78, 0.81, 0.75, 0.33, 0.12, 0.36, 0.16, 0.35, 0.98, 0.6, 0.2, 0.51, 0.21, 0.68, 0.02, 0.89, 0.07, 0.16, 0.75, 0.38, 0.61, 0.21, 0.96, 0.57, 0.04, 0.17, 0.86, 0.75, 0.56, 0.05, 0.88, 0.06, 0.27, 0.7, 0.49, 0.53, 0.7, 0.9, 0.44, 0.64, 0.73, 0.76, 0.62, 0.85, 0.35, 0.54, 0.27, 0.12, 0.04, 0.82, 0.54, 0.63, 0.15, 0.12, 0.13, 0.44, 0.47, 0.21, 0.27, 0.38, 0.85, 0.37, 0.49, 0.33, 0.63, 0.97, 0.93, 0.27, 0.67, 0.02, 0.44, 0.02, 0.64, 0.27, 0.9, 0.12, 0.58, 0.81, 0.44, 0.76, 0.16, 0.06, 0.11, 0.96, 0.23, 0.09, 0.01, 0.5, 0.16, 0.66, 0.7, 0.3, 0.75, 0.62, 0.32, 0.47, 0.84, 0.13, 0.82, 0.5, 0.91, 0.34, 0.5, 0.56, 0.1, 0.76, 0.38, 0.27, 0.8, 0.15, 0.44, 0.23, 0.33, 0.93, 0.01, 0.85, 0.83, 0.64, 0.21, 0.9, 0.32, 0.01, 0.7, 0.24, 0.12, 0.2, 0.69, 0.22, 0.99, 0.88, 0.2, 0.83, 0.89, 0.14, 0.2, 0.45, 0.1, 0.85, 0.61, 0.01, 0.4, 0.21, 0.95, 0.47, 0.76, 0.48, 0.62, 0.87, 0.87, 0.92, 0.32, 0.89, 0.96, 0.34, 0.89, 0.39, 0.48, 0.92, 0.93, 0.01, 0.07, 0.07, 0.44, 0.18, 0.97, 0.15, 0.22, 0.1, 0.26, 0.03, 0.89, 0.24, 0.72, 0.86, 0.07, 0.74, 0.44, 0.66, 0.6, 0.33, 0.75, 0.83, 0.94, 0.57, 0.09, 0.69, 0.65, 0.34, 0.84, 0.53, 0.86, 0.07, 0.51, 0.3, 0.1, 0.82, 0.21, 0.79, 0.09, 0.79, 0.89, 0.83, 0.75, 0.84, 0.12, 0.71, 0.63, 0.69, 0.41, 0.86, 0.53, 0.09, 0.05, 0.15, 0.37, 0.74, 0.93, 0.73, 0.88, 0.16, 0.45, 0.99, 0.07, 0.52, 0.71, 0.58, 0.29, 0.93, 0.81, 0.81, 0.84, 0.88, 0.76, 0.64, 0.19, 0.79, 0.61, 0.56, 0.77, 0.29, 0.6, 0.02, 0.38, 0.28, 0.65, 0.76, 0.17, 0.22, 0.54, 0.55, 0.04, 0.66, 0.17, 0.65, 0.33, 0.36, 0.42, 0.72, 0.35, 0.3, 0.35, 0.62, 0.62, 0.98, 0.38, 0.14, 0.55, 0.67, 0.97, 0.75, 0.74, 0.41, 0.93, 0.41, 0.73, 0.77, 0.26, 0.69, 0.6, 0.08, 0.9, 0.83, 0.1, 0.57, 0.47, 0.19, 0.06, 0.72, 0.19, 0.57, 0.9, 0.87, 0.81, 0.34, 0.84, 0.38, 0.52, 0.73, 0.35, 0.39, 0.27, 0.88, 0.08, 0.13, 0.17, 0.83, 0.15, 0.99, 0.54, 0.13, 0.63, 0.75, 0.85, 0.23, 0.55, 0.06, 0.99, 0.75, 0.36, 0.24, 0.83, 0.18, 0.9, 0.67, 0.86, 0.27, 0.57, 0.14, 0.99, 0.84, 0.15, 0.02, 0.65, 0.85, 0.3, 0.01, 0.97, 0.89, 0.82, 0.34, 0.93, 0.35, 0.71, 0.09, 0.24, 0.12, 0.57, 0.55, 0.79, 0.91, 0.54, 0.3, 0.62, 0.46, 0.02, 0.36, 0.55, 0.48, 0.5, 0.76, 0.28, 0.67, 0.85, 0.31, 0.39, 0.49, 0.52, 0.16, 0.78, 0.25, 0.32, 0.76, 0.47, 0.85, 0.29, 0.78, 0.41, 0.69, 0.1, 0.64, 0.48, 0.27, 0.03, 0.76, 0.9, 0.02, 0.22, 0.89, 0.91, 0.84, 0.98, 0.18, 0.78, 0.02, 0.07, 0.69, 0.52, 0.02, 0.75, 0.4, 0.97, 0.97, 0.46, 0.67, 0.88, 0.86, 0.27, 0.06, 0.24, 0.01, 0.37, 0.45, 0.49, 0.75, 0.91, 0.33, 0.71, 0.83, 0.43, 0.34, 0.22, 0.71, 0.17, 0.35, 0.9, 0.77, 0.78, 0.28, 0.15, 0.95, 0.61, 0.31, 0.21, 0.05, 0.87, 0.84, 0.63, 0.31, 0.28, 0.01, 0.48, 0.17, 0.15, 0.3, 0.85, 0.28, 0.22, 0.87, 0.92, 0.34, 0.22, 0.21, 0.21, 0.67, 0.49, 0.97, 0.56, 0.32, 0.7, 0.46, 0.7, 0.7, 0.7, 0.9, 0.07, 0.12, 0.66, 0.11, 0.42, 0.99, 0.26, 0.91, 0.67, 0.07, 0.37, 0.45, 0.69, 0.4, 0.81, 0.11, 0.16, 0.57, 0.37, 0.36, 0.27, 0.89, 0.76, 0.03, 0.97, 0.39, 0.25, 0.39, 0.68, 0.2, 0.12, 0.21, 0.82, 0.38, 0.13, 0.15, 0.79, 0.11, 0.5, 0.56, 0.13, 0.99, 0.79, 0.94, 0.04, 0.29, 0.49, 0.64, 0.63, 0.87, 0.51, 0.59, 0.56, 0.69, 0.96, 0.92, 0.08, 0.26, 0.52, 0.26, 0.65, 0.58, 0.44, 0.46, 0.02, 0.73, 0.4, 0.06, 0.56, 0.34, 0.8, 0.99, 0.48, 0.65, 0.92, 0.27, 0.85, 0.75, 0.55, 0.75, 0.25, 0.53, 0.57, 0.81, 0.05, 0.93, 0.42, 0.27, 0.67, 0.57, 0.91, 0.18, 0.93, 0.6, 0.07, 0.73, 0.15, 0.83, 0.31, 0.4, 0.39, 0.87, 0.89, 0.71, 0.49, 0.02, 0.58, 0.87, 0.19, 0.15, 0.45, 0.76, 0.9, 0.78, 0.24, 0.31, 0.08, 0.69, 0.48, 0.64, 0.67, 0.45, 0.21, 0.36, 0.22, 0.09, 0.31, 0.61, 0.15, 0.84, 0.73, 0.95, 0.78, 0.25, 0.05, 0.72, 0.96, 0.15, 0.3, 0.6, 0.24, 0.83, 0.09, 0.2, 0.07, 0.6, 0.12, 0.02, 0.46, 0.58, 0.06, 0.29, 0.27, 0.65, 0.76, 0.39, 0.34, 0.05, 0.92, 0.14, 0.46, 0.43, 0.46, 0.92, 0.91, 0.42, 0.89, 0.81, 0.17, 0.55, 0.45, 0.52, 0.94, 0.69, 0.48, 0.34, 0.25, 0.19, 0.05, 0.47, 0.13, 0.3, 0.01, 0.55, 0.32, 0.85, 0.44, 0.16, 0.15, 0.21, 0.47, 0.19, 0.49, 0.98, 0.86, 0.66, 0.7, 0.31, 0.38, 0.93, 0.12, 0.68, 0.9, 0.08, 0.1, 0.24, 0.67, 0.42, 0.04, 0.8, 0.5, 0.03, 0.86, 0.7, 0.16, 0.32, 0.62, 0.34, 0.72, 0.98, 0.1, 0.21, 0.99, 0.96, 0.2, 0.09, 0.91, 0.89, 0.88, 0.2, 0.58, 0.94, 0.17, 0.41, 0.34, 0.73, 0.7, 0.3, 0.29, 0.37, 0.45, 0.85, 0.41, 0.43, 0.01, 0.72, 0.66, 0.06, 0.95, 0.7, 0.55, 0.56, 0.91, 0.14, 0.67, 0.33, 0.87, 0.93, 0.71, 0.64, 0.41, 0.68, 0.92, 0.77, 0.74, 0.96, 0.1, 0.86, 0.94, 0.98, 0.24, 0.5, 0.64, 0.26, 0.93, 0.69, 0.59, 0.32, 0.7, 0.53, 0.06, 0.92, 0.06, 0.41, 0.55, 0.67, 0.13, 0.09, 0.67, 0.23, 0.39, 0.57, 0.51, 0.16, 0.45, 0.65, 0.17, 0.83, 0.98, 0.74, 0.71, 0.28, 0.91, 0.14, 0.52, 0.07, 0.34, 0.09, 0.76, 0.45, 0.8, 0.52, 0.5, 0.23, 0.39, 0.59, 0.99, 0.29, 0.26, 0.85, 0.08, 0.63, 0.86, 0.93, 0.24, 0.53, 0.48, 0.27, 0.58, 0.5, 0.5, 0.19, 0.24, 0.47, 0.01, 0.98, 0.91, 0.59, 0.1, 0.11, 0.86, 0.71, 0.98, 0.12, 0.43, 0.22, 0.57, 0.84, 0.47, 0.76, 0.64, 0.39, 0.37, 0.03, 0.31, 0.77, 0.14, 0.2, 0.92, 0.16, 0.72, 0.1, 0.95, 0.63, 0.19, 0.46, 0.11, 0.15, 0.16, 0.36, 0.6, 0.39, 0.91, 0.85, 0.89, 0.17, 0.59, 0.66, 0.39, 0.78, 0.98, 0.43, 0.29, 0.42, 0.51, 0.58, 0.04, 0.74, 0.33, 0.21, 0.21, 0.28, 0.03, 0.22, 0.85, 0.83, 0.92, 0.55, 0.08, 0.71, 0.84, 0.61, 0.96, 0.65, 0.4, 0.95, 0.15, 0.67, 0.48, 0.16, 0.35, 0.23, 0.08, 0.19, 0.11, 0.49, 0.28, 0.87, 0.71, 0.04, 0.87, 0.24, 0.83, 0.13, 0.84, 0.69, 0.38, 0.65, 0.39, 0.18, 0.47, 0.24, 0.08, 0.43, 0.38, 0.44, 0.04, 0.74, 0.59, 0.2, 0.85, 0.35, 0.22, 0.14, 0.02, 0.67, 0.08, 0.08, 0.32, 0.35, 0.33, 0.13, 0.45, 0.12, 0.2, 0.68, 0.95, 0.96, 0.66, 0.07, 0.2, 0.85, 0.37, 0.97, 0.58, 0.34, 0.2, 0.96, 0.16, 0.19, 0.05, 0.06, 0.14, 0.71, 0.1, 0.39, 0.66, 0.42, 0.38, 0.86, 0.27, 0.61, 0.64, 0.29, 0.29, 0.94, 0.29, 0.37, 0.59, 0.87, 0.82, 0.61, 0.62, 0.13, 0.19, 0.81, 0.34, 0.07, 0.22, 0.32, 0.73, 0.76, 0.14, 0.74, 0.5, 0.9, 0.33, 0.09, 0.04, 0.85, 0.62, 0.41, 0.63, 0.96, 0.5, 0.13, 0.77, 0.93, 0.13, 0.96, 0.37, 0.52, 0.57, 0.1, 0.97, 0.74, 0.97, 0.05, 0.49, 0.39, 0.47, 0.62, 0.66, 0.69, 0.03, 0.45, 0.47, 0.64, 0.86, 0.95, 0.35, 0.22, 0.05, 0.13, 0.33, 0.87, 0.82, 0.17, 0.01, 0.78, 0.24, 0.12, 0.23, 0.34, 0.51, 0.71, 0.35, 0.19, 0.22, 0.68, 0.17, 0.23, 0.85, 0.13, 0.26, 0.32, 0.71, 0.56, 0.8, 0.59, 0.61, 0.31, 0.83, 0.28, 0.78, 0.35, 0.65, 0.54, 0.58, 0.86, 0.71, 0.26, 0.45, 0.86, 0.01, 0.05, 0.38, 0.46, 0.99, 0.75, 0.24, 0.63, 0.61, 0.45, 0.57, 0.66, 0.31, 0.94, 0.9, 0.57, 0.02, 0.82, 0.76, 0.33, 0.33, 0.33, 0.15, 0.24, 0.46, 0.74, 0.87, 0.96, 0.88, 0.94, 0.23, 0.69, 0.27, 0.55, 0.53, 0.97, 0.43, 0.35, 0.35, 0.3, 0.72, 0.34, 0.71, 0.14, 0.35, 0.69, 0.72, 0.78, 0.99, 0.71, 0.24, 0.87, 0.42, 0.92, 0.67, 0.79, 0.82, 0.63, 0.7, 0.59, 0.39, 0.13, 0.36, 0.93, 0.17, 0.78, 0.75, 0.14, 0.38, 0.94, 0.96, 0.23, 0.75, 0.75, 0.2, 0.06, 0.36, 0.08, 0.28, 0.84, 0.3, 0.24, 0.83, 0.36, 0.61, 0.89, 0.93, 0.84, 0.36, 0.1, 0.5, 0.7, 0.2, 0.87, 0.28, 0.78, 0.95, 0.09, 0.49, 0.1, 0.07, 0.55, 0.28, 0.49, 0.03, 0.31, 0.04, 0.76, 0.52, 0.29, 0.6, 0.29, 0.91, 0.42, 0.68, 0.76, 0.41, 0.29, 0.94, 0.08, 0.27, 0.11, 0.79, 0.42, 0.67, 0.73, 0.17, 0.04, 0.56, 0.52, 0.76, 0.9, 0.86, 0.55, 0.89, 0.32, 0.98, 0.13, 0.13, 0.55, 0.77, 0.47, 0.65, 0.37, 0.01, 0.11, 0.07, 0.32, 0.87, 0.77, 0.34, 0.66, 0.21, 0.86, 0.96, 0.76, 0.03, 0.19, 0.08, 0.51, 0.8, 0.04, 0.5, 0.07, 0.34, 0.65, 0.29, 0.09, 0.13, 0.15, 0.83, 0.26, 0.67, 0.99, 0.55, 0.66, 0.71, 0.94, 0.25, 0.67, 0.35, 0.18, 0.02, 0.42, 0.25, 0.88, 0.34, 0.22, 0.52, 0.65, 0.39, 0.37, 0.18, 0.97, 0.2, 0.32, 0.63, 0.03, 0.66, 0.04, 0.32, 0.96, 0.88, 0.4, 0.95, 0.81, 0.54, 0.69, 0.62, 0.9, 0.56, 0.15, 0.3, 0.1, 0.17, 0.96, 0.07, 0.62, 0.6, 0.28, 0.55, 0.93, 0.69, 0.02, 0.68, 0.72, 0.39, 0.13, 0.09, 0.69, 0.26, 0.39, 0.86, 0.47, 0.25, 0.66, 0.33, 0.01, 0.45, 0.75, 0.44, 0.07, 0.1, 0.65, 0.91, 0.7, 0.36, 0.18, 0.6, 0.18, 0.46, 0.05, 0.38, 0.86, 0.09, 0.5, 0.42, 0.12, 0.9, 0.64, 0.71, 0.37, 0.01, 0.03, 0.86, 0.98, 0.04, 0.57, 0.12, 0.28, 0.34, 0.23, 0.09, 0.24, 0.55, 0.16, 0.74, 0.81, 0.94, 0.25, 0.23, 0.86, 0.75, 0.09, 0.09, 0.99, 0.72, 0.15, 0.29, 0.13, 0.71, 0.72, 0.77, 0.1, 0.43, 0.47, 0.95, 0.33, 0.72, 0.61, 0.91, 0.1, 0.74, 0.09, 0.23, 0.74, 0.12, 0.44, 0.3, 0.27, 0.89, 0.41, 0.13, 0.98, 0.65, 0.37, 0.59, 0.77, 0.92, 0.1, 0.74, 0.39, 0.2, 0.7, 0.78, 0.6, 0.07, 0.86, 0.53, 0.43, 0.23, 0.73, 0.3, 0.62, 0.55, 0.14, 0.32, 0.07, 0.41, 0.29, 0.46, 0.41, 0.46, 0.61, 0.66, 0.45, 0.85, 0.82, 0.18, 0.82, 0.39, 0.83, 0.4, 0.65, 0.71, 0.19, 0.26, 0.62, 0.31, 0.15, 0.69, 0.5, 0.38, 0.31, 0.81, 0.56, 0.75, 0.48, 0.66, 0.35, 0.2, 0.05, 0.76, 0.12, 0.99, 0.12, 0.07, 0.24, 0.89, 0.35, 0.35, 0.29, 0.44, 0.72, 0.94, 0.98, 0.44, 0.96, 0.88, 0.95, 0.54, 0.94, 0.85, 0.25, 0.51, 0.51, 0.45, 0.46, 0.11, 0.14, 0.51, 0.39, 0.09, 0.36, 0.03, 0.55, 0.11, 0.32, 0.89, 0.72, 0.73, 0.49, 0.89, 0.52, 0.92, 0.74, 0.4, 0.57, 0.81, 0.38, 0.54, 0.33, 0.32, 0.76, 0.26, 0.63, 0.33, 0.36, 0.34, 0.73, 0.13, 0.29, 0.38, 0.49, 0.51, 0.03, 0.38, 0.13, 0.97, 0.01, 0.34, 0.43, 0.07, 0.47, 0.32, 0.98, 0.21, 0.55, 0.54, 0.29, 0.45, 0.79, 0.07, 0.37, 0.49, 0.19, 0.76, 0.69, 0.24, 0.43, 0.8, 0.5, 0.79, 0.02, 0.91, 0.19, 0.54, 0.63, 0.56, 0.63, 0.9, 0.03, 0.53, 0.69, 0.85, 0.78, 0.78, 0.65, 0.15, 0.74, 0.99, 0.06, 0.05, 0.34, 0.66, 0.49, 0.41, 0.05, 0.64, 0.65, 0.61, 0.49, 0.44, 0.36, 0.85, 0.52, 0.97, 0.96, 0.97, 0.93, 0.44, 0.97, 0.93, 0.27, 0.03, 0.83, 0.17, 0.23, 0.64, 0.25, 0.72, 0.13, 0.82, 0.6, 0.56, 0.73, 0.61, 0.72, 0.25, 0.67, 0.88, 0.17, 0.24, 0.96, 0.08, 0.14, 0.46, 0.11, 0.4, 0.89, 0.31, 0.82, 0.8, 0.25, 0.85, 0.87, 0.37, 0.25, 0.12, 0.26, 0.83, 0.57, 0.36, 0.97, 0.73, 0.04, 0.83, 0.21, 0.42, 0.01, 0.5, 0.74, 0.88, 0.25, 0.85, 0.03, 0.53, 0.28, 0.47, 0.41, 0.95, 0.82, 0.92, 0.79, 0.71, 0.85, 0.74, 0.64, 0.72, 0.27, 0.89, 0.89, 0.18, 0.79, 0.57, 0.92, 0.57, 0.09, 0.56, 0.58, 0.35, 0.26, 0.7, 0.68, 0.65, 0.77, 0.32, 0.59, 0.75, 0.94, 0.94, 0.83, 0.43, 0.22, 0.74, 0.47, 0.16, 0.26, 0.27, 0.47, 0.91, 0.62, 0.93, 0.46, 0.24, 0.19, 0.97, 0.07, 0.16, 0.34, 0.42, 0.43, 0.05, 0.68, 0.52, 0.84, 0.13, 0.47, 0.32, 0.85, 0.85, 0.52, 0.92, 0.88, 0.16, 0.07, 0.49, 0.28, 0.18, 0.91, 0.29, 0.7, 0.48, 0.68, 0.43, 0.91, 0.81, 0.26, 0.48, 0.75, 0.5, 0.64, 0.17, 0.82, 0.65, 0.9, 0.03, 0.13, 0.31, 0.97, 0.96, 0.21, 0.17, 0.82, 0.48, 0.77, 0.16, 0.24, 0.99, 0.37, 0.91, 0.68, 0.95, 0.93, 0.54, 0.72, 0.9, 0.26, 0.54, 0.51, 0.04, 0.73, 0.14, 0.95, 0.47, 0.99, 0.85, 0.22, 0.38, 0.56, 0.75, 0.18, 0.96, 0.17, 0.69, 0.51, 0.76, 0.89, 0.93, 0.88, 0.85, 0.57, 0.87, 0.54, 0.18, 0.69, 0.47, 0.32, 0.75, 0.82, 0.39, 0.16, 0.2, 0.54, 0.45, 0.16, 0.04, 0.68, 0.95, 0.89, 0.49, 0.01, 0.22, 0.18, 0.02, 0.93, 0.38, 0.46, 0.17, 0.86, 0.97, 0.06, 0.64, 0.57, 0.91, 0.17, 0.66, 0.69, 0.93, 0.44, 0.77, 0.03, 0.85, 0.35, 0.88, 0.39, 0.56, 0.56, 0.03, 0.14, 0.66, 0.32, 0.69, 0.05, 0.45, 0.91, 0.29, 0.77, 0.04, 0.8, 0.22, 0.71, 0.59, 0.52, 0.78, 0.41, 0.79, 0.5, 0.21, 0.68, 0.65, 0.63, 0.42, 0.27, 0.69, 0.4, 0.45, 0.27, 0.94, 0.87, 0.51, 0.01, 0.79, 0.15, 0.83, 0.08, 0.02, 0.84, 0.36, 0.97, 0.78, 0.46, 0.48, 0.56, 0.6, 0.38, 0.13, 0.99, 0.63, 0.85, 0.69, 0.37, 0.91, 0.34, 0.36, 0.55, 0.85, 0.77, 0.07, 0.73, 0.52, 0.79, 0.12, 0.97, 0.23, 0.03, 0.06, 0.97, 0.21, 0.15, 0.12, 0.65, 0.74, 0.14, 0.32, 0.23, 0.5, 0.65, 0.2, 0.94, 0.03, 0.97, 0.2, 0.58, 0.85, 0.61, 0.15, 0.57, 0.72, 0.99, 0.86, 0.13, 0.61, 0.02, 0.41, 0.64, 0.52, 0.35, 0.32, 0.77, 0.75, 0.38, 0.86, 0.83, 0.98, 0.96, 0.25, 0.99, 0.36, 0.42, 0.54, 0.41, 0.02, 0.59, 0.23, 0.79, 0.45, 0.96, 0.42, 0.64, 0.67, 0.28, 0.14, 0.7, 0.47, 0.97, 0.1, 0.97, 0.08, 0.75, 0.33, 0.51, 0.03, 0.47, 0.73, 0.46, 0.86, 0.79, 0.34, 0.12, 0.08, 0.49, 0.68, 0.43, 0.42, 0.54, 0.93, 0.84, 0.37, 0.23, 0.4, 0.97, 0.6, 0.73, 0.11, 0.96, 0.59, 0.07, 0.23, 0.75, 0.57, 0.3, 0.55, 0.67, 0.13, 0.76, 0.63, 0.77, 0.65, 0.1, 0.7, 0.84, 0.93, 0.02, 0.95, 0.96, 0.93, 0.4, 0.53, 0.58, 0.87, 0.49, 0.59, 0.56, 0.95, 0.11, 0.78, 0.86, 0.28, 0.71, 0.79, 0.53, 0.88, 0.86, 0.11, 0.33, 0.83, 0.2, 0.37, 0.41, 0.04, 0.85, 0.48, 0.81, 0.36, 0.86, 0.21, 0.92, 0.24, 0.62, 0.78, 0.68, 0.37, 0.22, 0.45, 0.62, 0.42, 0.23, 0.97, 0.89, 0.83, 0.89, 0.93, 0.51, 0.53, 0.05, 0.25, 0.54, 0.94, 0.35, 0.46, 0.36, 0.44, 0.06, 0.27, 0.23, 0.08, 0.03, 0.78, 0.26, 0.95, 0.54, 0.56, 0.29, 0.65, 0.92, 0.91, 0.54, 0.68, 0.3, 0.93, 0.84, 0.52, 0.75, 0.5, 0.87, 0.41, 0.91, 0.79, 0.42, 0.09, 0.61, 0.26, 0.17, 0.1, 0.15, 0.52, 0.86, 0.18, 0.63, 0.97, 0.88, 0.66, 0.69, 0.45, 0.21, 0.76, 0.78, 0.43, 0.31, 0.72, 0.84, 0.24, 0.92, 0.32, 0.51, 0.12, 0.44, 0.73, 0.72, 0.59, 0.74, 0.56, 0.13, 0.08, 0.28, 0.76, 0.66, 0.52, 0.21, 0.95, 0.66, 0.75, 0.82, 0.83, 0.39, 0.34, 0.05, 0.57, 0.12, 0.07, 0.11, 0.82, 0.46, 0.15, 0.25, 0.48, 0.66, 0.99, 0.13, 0.53, 0.04, 0.25, 0.07, 0.55, 0.11, 0.3, 0.13, 0.6, 0.41, 0.05, 0.12, 0.22, 0.1, 0.4, 0.2, 0.98, 0.4, 0.27, 0.64, 0.62, 0.51, 0.71, 0.75, 0.74, 0.99, 0.67, 0.53, 0.73, 0.1, 0.1, 0.35, 0.12, 0.67, 0.22, 0.74, 0.85, 0.45, 0.02, 0.02, 0.52, 0.14, 0.97, 0.07, 0.9, 0.35, 0.73, 0.53, 0.08, 0.82, 0.3, 0.12, 0.78, 0.07, 0.17, 0.46, 0.35, 0.15, 0.6, 0.06, 0.97, 0.39, 0.46, 0.75, 0.82, 0.83, 0.2, 0.98, 0.77, 0.6, 0.9, 0.76, 0.36, 0.16, 0.22, 0.08, 0.01, 0.12, 0.01, 0.01, 0.92, 0.53, 0.89, 0.36, 0.74, 0.61, 0.38, 0.9, 0.51, 0.29, 0.17, 0.83, 0.96, 0.99, 0.4, 0.06, 0.8, 0.65, 0.94, 0.5, 0.62, 0.7, 0.67, 0.19, 0.74, 0.13, 0.7, 0.54, 0.59, 0.47, 0.37, 0.8, 0.07, 0.53, 0.74, 0.3, 0.8, 0.92, 0.45, 0.07, 0.46, 0.98, 0.3, 0.4, 0.71, 0.11, 0.68, 0.27, 0.4, 0.06, 0.17, 0.36, 0.17, 0.96, 0.81, 0.74, 0.43, 0.95, 0.18, 0.31, 0.51, 0.78, 0.99, 0.54, 0.16, 0.27, 0.58, 0.65, 0.71, 0.58, 0.68, 0.57, 0.62, 0.43, 0.14, 0.25, 0.62, 0.49, 0.9, 0.69, 0.35, 0.13, 0.21, 0.36, 0.03, 0.26, 0.64, 0.45, 0.89, 0.08, 0.05, 0.78, 0.23, 0.12, 0.07, 0.95, 0.2, 0.54, 0.78, 0.13, 0.76, 0.15, 0.61, 0.11, 0.1, 0.33, 0.97, 0.88, 0.94, 0.43, 0.01, 0.05, 0.11, 0.13, 0.71, 0.2, 0.46, 0.07, 0.1, 0.69, 0.89, 0.52, 0.66, 0.89, 0.65, 0.22, 0.23, 0.68, 0.93, 0.24, 0.66, 0.86, 0.88, 0.14, 0.08, 0.26, 0.93, 0.1, 0.08, 0.94, 0.87, 0.67, 0.43, 0.79, 0.32, 0.79, 0.74, 0.19, 0.23, 0.99, 0.89, 0.88, 0.55, 0.11, 0.04, 0.99, 0.38, 0.44, 0.88, 0.51, 0.22, 0.9, 0.54, 0.81, 0.18, 0.45, 0.9, 0.83, 0.61, 0.12, 0.27, 0.71, 0.6, 0.43, 0.23, 0.7, 0.07, 0.99, 0.49, 0.58, 0.05, 0.14, 0.1, 0.92, 0.11, 0.49, 0.6, 0.35, 0.48, 0.79, 0.68, 0.07, 0.71, 0.25, 0.34, 0.61, 0.64, 0.48, 0.19, 0.74, 0.11, 0.61, 0.17, 0.85, 0.33, 0.88, 0.88, 0.96, 0.04, 0.78, 0.08, 0.75, 0.29, 0.37, 0.45, 0.48, 0.16, 0.16, 0.29, 0.83, 0.79, 0.56, 0.7, 0.01, 0.75, 0.88, 0.67, 0.1, 0.81, 0.77, 0.83, 0.5, 0.74, 0.21, 0.14, 0.14, 0.65, 0.02, 0.33, 0.12, 0.92, 0.02, 0.18, 0.15, 0.71, 0.1, 0.41, 0.12, 0.87, 0.91, 0.14, 0.56, 0.37, 0.13, 0.6, 0.83, 0.16, 0.18, 0.12, 0.64, 0.8, 0.66, 0.43, 0.66, 0.7, 0.45, 0.09, 0.08, 0.63, 0.89, 0.94, 0.83, 0.9, 0.41, 0.98, 0.99, 0.32, 0.91, 0.15, 0.86, 0.56, 0.94, 0.56, 0.28, 0.93, 0.54, 0.01, 0.69, 0.54, 0.94, 0.13, 0.3, 0.3, 0.86, 0.62, 0.42, 0.62, 0.05, 0.23, 0.15, 0.89, 0.08, 0.68, 0.11, 0.75, 0.28, 0.83, 0.69, 0.22, 0.81, 0.29, 0.16, 0.99, 0.1, 0.53, 0.61, 0.9, 0.76, 0.5, 0.81, 0.07, 0.48, 0.23, 0.87, 0.31, 0.11, 0.02, 0.34, 0.64, 0.04, 0.15, 0.18, 0.7, 0.81, 0.71, 0.99, 0.04, 0.13, 0.42, 0.32, 0.57, 0.58, 0.15, 0.85, 0.48, 0.19, 0.68, 0.63, 0.67, 0.35, 0.14, 0.48, 0.18, 0.21, 0.13, 0.7, 0.51, 0.04, 0.85, 0.32, 0.58, 0.26, 0.48, 0.14, 0.47, 0.56, 0.49, 0.17, 0.02, 0.98, 0.93, 0.46, 0.68, 0.24, 0.77, 0.26, 0.67, 0.25, 0.71, 0.28, 0.64, 0.67, 0.62, 0.98, 0.08, 0.02, 0.92, 0.03, 0.23, 0.54, 0.28, 0.08, 0.17, 0.64, 0.32, 0.78, 0.57, 0.24, 0.55, 0.33, 0.46, 0.72, 0.69, 0.35, 0.55, 0.56, 0.36, 0.62, 0.26, 0.25, 0.82, 0.1, 0.01, 0.19, 0.11, 0.74, 0.66, 0.73, 0.5, 0.92, 0.05, 0.51, 0.44, 0.42, 0.27, 0.37, 0.77, 0.87, 0.89, 0.64, 0.63, 0.36, 0.51, 0.88, 0.64, 0.37, 0.12, 0.39, 0.44, 0.46, 0.4, 0.88, 0.77, 0.77, 0.6, 0.3, 0.64, 0.05, 0.53, 0.57, 0.71, 0.36, 0.52, 0.03, 0.24, 0.82, 0.66, 0.25, 0.73, 0.19, 0.19, 0.64, 0.17, 0.05, 0.8, 0.75, 0.74, 0.31, 0.21, 0.94, 0.08, 0.5, 0.43, 0.86, 0.98, 0.64, 0.99, 0.42, 0.41, 0.05, 0.15, 0.1, 0.96, 0.89, 0.54, 0.15, 0.86, 0.6, 0.33, 0.97, 0.34, 0.17, 0.59, 0.22, 0.13, 0.17, 0.73, 0.25, 0.65, 0.38, 0.96, 0.34, 0.8, 0.84, 0.38, 0.55, 0.78, 0.36, 0.21, 0.69, 0.08, 0.29, 0.25, 0.21, 0.06, 0.87, 0.16, 0.27, 0.18, 0.5, 0.6, 0.24, 0.31, 0.7, 0.45, 0.72, 0.4, 0.16, 0.62, 0.81, 0.79, 0.53, 0.2, 0.87, 0.16, 0.05, 0.53, 0.95, 0.64, 0.32, 0.6, 0.87, 0.96, 0.64, 0.22, 0.44, 0.49, 0.55, 0.61, 0.49, 0.95, 0.45, 0.68, 0.51, 0.8, 0.1, 0.21, 0.82, 0.6, 0.2, 0.35, 0.19, 0.22, 0.02, 0.35, 0.07, 0.46, 0.28, 0.69, 0.29, 0.61, 0.47, 0.38, 0.97, 0.85, 0.61, 0.08, 0.76, 0.93, 0.71, 0.79, 0.07, 0.78, 0.91, 0.83, 0.87, 0.26, 0.76, 0.72]


tails = []

product = 1
for i in range(len(heads)):
    tails.append((1-heads[i]))
    product *= heads[i]


def solve(heads, tails, index, count, product, k):
    if index >= len(heads):
        return product
    elif count >= k:
        return product
    else:
        ans = 0
        ans += solve(heads, tails, index+1, count+1, ((product * tails[index])/heads[index]), k) + solve(heads, tails, index+1, count, product, k)
        return ans

print(solve(heads, tails, 0, 0, product, (n-1)//2))

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if i * 500 + j * 100 + k * 50 == X:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
P = list(map(float, input().split()))
import numpy as np
def prob_ret():
  prob = [0.0]*(N+1)
  prob[0] = 1
  prob=np.array(prob)
  for n in range(N):
    p = prob[:n]*P[n]
    prob[:n] = prob[:n] * (1-P[n])
    prob[1:] = prob[1:] + p
  return sum(prob[N//2+1:])
print(prob_ret())

Submission status: Runtime Error

Solution code:
# import numpy as np
n=int(input())
l=input().split()
l=[float(x) for x in l]
t=(n+1)//2
dp=[[-1 for i in range(n+1)]for i in range(n+1)]
def recur(i,k,ans):
    if i==0:
        # global ans
        if k>=t:
            return 1
            
        return 0
    # a=dp[i][k]
    # dp[i][k]=recur(i+1,k+1,p*l[i],ans)+recur(i+1,k,p*(1-l[i]),ans)
    # b=dp[i][k]
    # if a!=0 and a!=b:
    #     print(a,b)
    # return dp[i][k]
    if dp[i][k]!=-1:
        return dp[i][k]
    
    dp[i][k]=l[i-1]*recur(i-1,k+1,ans)+recur(i-1,k,ans)*(1-l[i-1])
    # print(dp[i][k])
    # if dp[i+1][k+1] == 0:
    #     dp[i+1][k+1]=recur(i+1,k+1,p*l[i])
    # if dp[i+1][k]==0:
    #     dp[i+1][k]=recur(i+1,k,p*(1-l[i]))
    return dp[i][k]
# ans=0
# print(dp)
print("%0.10f"%recur(n,0,0))
# print(dp)
# print(ans)

Submission status: Runtime Error

Solution code:
# import numpy as np
n=int(input())
l=list(map(float,input().split()))
t=(n+1)//2
dp=[[-1 for i in range(n+1)]for i in range(n+1)]
def recur(i,k,ans):
    if i==n:
        # global ans
        if k>=t:
            return 1
            
        return 0
    # a=dp[i][k]
    # dp[i][k]=recur(i+1,k+1,p*l[i],ans)+recur(i+1,k,p*(1-l[i]),ans)
    # b=dp[i][k]
    # if a!=0 and a!=b:
    #     print(a,b)
    # return dp[i][k]
    if dp[i][k]!=-1:
        return dp[i][k]
    
    dp[i][k]=l[i]*recur(i+1,k+1,ans)+recur(i+1,k,ans)*(1-l[i])
    # print(dp[i][k])
    # if dp[i+1][k+1] == 0:
    #     dp[i+1][k+1]=recur(i+1,k+1,p*l[i])
    # if dp[i+1][k]==0:
    #     dp[i+1][k]=recur(i+1,k,p*(1-l[i]))
    return dp[i][k]
# ans=0
# print(dp)
print("%0.10f"%recur(0,0,0))
# print(dp)
# print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n=int(input())
l=list(map(float,input().split()))
t=(n+1)//2
dp=[[-1 for i in range(n+1)]for i in range(n+1)]
def recur(i,k,ans):
    if i==n:
        # global ans
        if k>=t:
            return 1
            
        return 0
    # a=dp[i][k]
    # dp[i][k]=recur(i+1,k+1,p*l[i],ans)+recur(i+1,k,p*(1-l[i]),ans)
    # b=dp[i][k]
    # if a!=0 and a!=b:
    #     print(a,b)
    # return dp[i][k]
    if dp[i][k]!=-1:
        return dp[i][k]
    
    dp[i][k]=l[i]*recur(i+1,k+1,ans)+recur(i+1,k,ans)*(1-l[i])
    # print(dp[i][k])
    # if dp[i+1][k+1] == 0:
    #     dp[i+1][k+1]=recur(i+1,k+1,p*l[i])
    # if dp[i+1][k]==0:
    #     dp[i+1][k]=recur(i+1,k,p*(1-l[i]))
    return dp[i][k]
# ans=0
# print(dp)
print("%0.10f"%recur(0,0,0))
# print(dp)
# print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n=int(input())
l=list(map(float,input().split()))
t=(n+1)//2
dp=[[-1 for i in range(n+1)]for i in range(n+1)]
def recur(i,k,ans):
    if i==n:
        # global ans
        if k>=t:
            return 1
            
        return 0
    # a=dp[i][k]
    # dp[i][k]=recur(i+1,k+1,p*l[i],ans)+recur(i+1,k,p*(1-l[i]),ans)
    # b=dp[i][k]
    # if a!=0 and a!=b:
    #     print(a,b)
    # return dp[i][k]
    if dp[i][k]!=-1:
        return dp[i][k]
    
    dp[i][k]=l[i]*recur(i+1,k+1,ans)+recur(i+1,k,ans)*(1-l[i])
    # print(dp[i][k])
    # if dp[i+1][k+1] == 0:
    #     dp[i+1][k+1]=recur(i+1,k+1,p*l[i])
    # if dp[i+1][k]==0:
    #     dp[i+1][k]=recur(i+1,k,p*(1-l[i]))
    return dp[i][k]
# ans=0
# print(dp)
print(recur(0,0,0))
# print(dp)
# print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
p=list(map(float, input().split())
       
dp=[[0 for i in range(n+1)] for j in range(n+1)]
dp[0][0]=1

for i in range(1,n+1):
       for j in range(n+1):
       	if j==0:
       		dp[i][j]=(1.0-p[i-1])*dp[i-1][j]
       	else:
       		dp[i][j]=p[i-1]*dp[i-1][j-1]+(1.0-p[i-1])*dp[i-1][j]
res=0
for i in range(n//2+1,n+1):
       res+=dp[n][i]
print(res)

Submission status: Runtime Error

Solution code:

n=int(input())

p=list(map(float,input().split()))

dp= [[0 for i in range(n+1)]for j in range(n+1)]

dp[0][0]=1.0

for i in range(1,n+1):
	for j in range(0,n+1):
		if(j==0):
			dp[i][j]=(1.0-p[i-1])*dp[i-1][j]
			
		else:
			dp[i][j]=p[i-1]*dp[i-1][j-1]+(1.0-p[i-1])*dp[i-1][j]
			

res=0.0

for i in range(n//2+1,n+1):
	res=res+dp[n][i]


print(res);

Submission status: Runtime Error

Solution code:
from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 6)

p = None


@lru_cache
def rec(i, j):
    if i < 0 or j < 0:
        return 0.0
    if i == 0 and j == 0:
        return 1.0
    return rec(i - 1, j) * (1 - p[i - 1]) + rec(i - 1, j - 1) * p[i - 1]


def main():
    N = int(input())
    global p
    p = list(map(float, input().split()))
    ans = 0
    for i in range(N // 2 + 1, N + 1):
        ans += rec(N, i)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 6)


@lru_cache
def rec(i, j):
    if i < 0 or j < 0:
        return 0.0
    if i == 0 and j == 0:
        return 1.0
    global p
    return rec(i - 1, j) * (1 - p[i - 1]) + rec(i - 1, j - 1) * p[i - 1]


def main():
    N = int(input())
    global p
    p = list(map(float, input().split()))
    ans = 0
    for i in range(N // 2 + 1, N + 1):
        ans += rec(N, i)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 6)


@lru_cache
def rec(i, j):
    global p
    if i < 0 or j < 0:
        return 0.0
    return rec(i - 1, j) * (1 - p[i - 1]) + \
        rec(i - 1, j - 1) * p[i - 1]


def main():
    N = int(input())
    global p
    p = list(map(float, input().split()))
    ans = 0
    for i in range(N//2+1, N+1):
        ans += rec(N, i)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
# python3だとTLE,pypy3だとAC

def get(i, j):
    global dp
    global p
    if i < 0 or j < 0:
        return 0.0
    if dp[i][j] == 0.0:
        dp[i][j] = get(i - 1, j) * (1 - p[i - 1]) + \
            get(i - 1, j - 1) * p[i - 1]
    return dp[i][j]


def main():
    N = int(input())
    global dp
    global p
    p = list(map(float, input().split()))
    dp = [[0.0] * (N + 1) for _ in range(N + 1)]
    dp[0][0] = 1.0
    for i in range(N, 0, -1):
        get(N, i)
    print(sum(dp[N][N//2+1:]))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
p = list(map(float, input().split()))

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
# dp[0][0] = 1-p[0]
# dp[0][1] = p[0]

for i in range(N):
    for j in range(i+1):
        # print(f"i {i}, j {j}")
        # print(f"p[i] {p[i]}, dp[i][j] {dp[i][j]}")

        if i == 0:
            dp[i+1][j] += 1-p[i]
            dp[i+1][j+1] += p[i]
        else:
            dp[i+1][j] += (1-p[i])*dp[i][j]
            dp[i+1][j+1] += p[i]*dp[i][j]
        # print("dp", dp)

ans = 0
for i, v in enumerate(dp[-1]):
    if i > N//2:
        ans += v
print(ans)N = int(input())
p = list(map(float, input().split()))

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
# dp[0][0] = 1-p[0]
# dp[0][1] = p[0]

for i in range(N):
    for j in range(i+1):
        # print(f"i {i}, j {j}")
        # print(f"p[i] {p[i]}, dp[i][j] {dp[i][j]}")

        if i == 0:
            dp[i+1][j] += 1-p[i]
            dp[i+1][j+1] += p[i]
        else:
            dp[i+1][j] += (1-p[i])*dp[i][j]
            dp[i+1][j+1] += p[i]*dp[i][j]
        # print("dp", dp)

ans = 0
for i, v in enumerate(dp[-1]):
    if i > N//2:
        ans += v
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
import math
p=list(map(float,input().split()))
for i in range(n):
    p[i]=p[i]*100
dp=[[0]*(n) for i in range(n+1)]
dp[0][0]=(100-p[0])
for i in range(1,n):
    dp[0][i]=dp[0][i-1]*(100-p[i])
# print(dp[0][1],1-p[2],dp[0][1]*(1-p[2]))
for i in range(1,n+1):
    for j in range(i-1,n):
        if j==0:
            temp1=1 
            temp2=0 
        else:
            temp1=dp[i-1][j-1]
            temp2=dp[i][j-1]
        dp[i][j]=temp1*p[j]+temp2*(100-p[j])
        dp[i][j]=dp[i][j]
ans=0
# print(dp)
den=100**(n)
for i in range(n//2+1,n+1):
    ans+=dp[i][n-1]

print(round(ans/den,10))

Submission status: Runtime Error

Solution code:
import numpy as np
n,l=int(input()),list(map(float,input().split()))
dp=np.full([n+1,n+1],0.0)
dp[0][0]=1.0

Submission status: Runtime Error

Solution code:
import numpy as np
n,l=int(input()),list(map(float,input().split()))
dp=np.full([n+1,n+1],0.0)
dp[0][0]=1.0
for i in range(1,n+1):
    for j in range(i+1):
        if j==0:
            dp[i][j]=dp[i-1][j]*(1.0-l[i-1])
        else:
            dp[i][j]=dp[i-1][j]*(1.0-l[i-1])+dp[i-1][j-1]*l[i-1]
a=0.0
for i in range((n+1)//2,n+1):
    a+=dp[n][i]
print(a)

Submission status: Runtime Error

Solution code:
import numpy as np
n,l=int(input()),list(map(float,input().split()))
dp=np.full([n+1,n+1],0.0)
dp[0][0]=1.0
for i in range(1,n+1):
    for j in range(i+1):
        if j==0:
            dp[i][j]=dp[i-1][j]*(1.0-l[i-1])
        else:
            dp[i][j]=dp[i-1][j]*(1.0-l[i-1])+dp[i-1][j-1]*l[i-1]
print(sum(dp[n][((n+1)//2):]))

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    p = tuple(map(float, input().split()))
    
    dp = [[0.0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = 1.0 
    for i0 in range(1, n + 1):
        dp[i0][0] = dp[i0-1][0] * pr[i0-1]

    for i1 in range(1, n + 1):
        pe = p[i1 - 1]
        pre = 1 - pe
        for i2 in range(1, i1 + 1):
            dp[i1][i2] = dp[i1-1][i2] * pre + dp[i1-1][i2-1] * pe

    r = sum(dp[n][n//2+1:])
    print(r)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np


def main():
    n = int(input())
    p = list(map(float, input().split()))

    dp = np.zeros((n + 1, n + 1), dtype='float64')
    dp[0, 0] = 1.0

    for i in range(n):
        for j in range(i + 1):
            dp[i + 1, j + 1] += dp[i, j] * p[i]
            dp[i + 1, j    ] += dp[i, j] * (1.0 - p[i])
    print(dp)
    res = 0.0
    for j in range(n // 2 + 1, n + 1):
        print(f'dp[{n},{j}]={dp[n, j]}')
        res += dp[n, j]
    print(res)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

def Probability(p,n):
    dp = [[0 for i in range(n+1)] for j in range(n+1)]
   
    dp[0][0] = 1.0
    
    for i in range(1,n+1):
        for j in range(0,n+1):
            if j==0:
                dp[i][j] = dp[i - 1][j] * (1.0 - p[i-1]) 
            else : 
                dp[i][j] = (dp[i - 1][j] * (1.0 - p[i-1]) +
                            dp[i - 1][j - 1] * p[i-1])  
    ans=0.0
    for i in range((n+1)//2,n+1):
        ans+=dp[n][i]
    return ans 

n=int(input())
a=list(map(float,input().split()))

 

print(Probability(a,n))