| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 8 초 (추가 시간 없음) | 1024 MB | 3 | 1 | 1 | 100.000% |
You are playing a first-person shooter with your friends. In this game, n players are divided into two teams fighting against each other. Each player is crowned with a balloon on top of the head, and players try to pop the balloons of the players of the opposing team.
Players are numbered from 1 through n, which are called the action orders. Also, each player is given a real number called the hit probability. The game consists of n phases. In the i-th (i = 1, …, n) phase, the player of the action order i (the attacker) takes the following action.
The game ends when all of the phases are completed.
You don't want any of the players of your team to be killed. Calculate the probability of keeping all the players of your team alive until the end of the game by optimally choosing the targets. Assume that the opposing players choose their targets at random.
The input consists of multiple datasets, each in the following format. The number of datasets does not exceed 50.
n
s1 p1
⋮
sn pn
The integer n is the number of the players between 2 and 300, inclusive. For each i = 1, …, n, si and pi represent the team and the hit probability of the player of action order i, respectively. si is a string either of "Ally" or "Enemy", which means that the player belongs to your team or the opposite, respectively. pi is a real number between 0 and 1, inclusive, with 9 digits after the decimal point. It is guaranteed that both teams have at least one player.
The end of the input is indicated by a line consisting of a zero.
For each dataset, output in a line the probability of keeping all the players of your team alive when targets are optimally selected. The absolute or relative error must be less than or equal to 10−9.
3 Ally 0.800000000 Enemy 0.300000000 Enemy 0.600000000 2 Enemy 0.444444444 Ally 0.111111111 5 Ally 0.500000000 Ally 0.750000000 Enemy 0.400000000 Enemy 0.100000000 Enemy 0.800000000 6 Ally 0.250000000 Ally 0.300000000 Enemy 0.200000000 Ally 0.800000000 Enemy 1.000000000 Enemy 0.750000000 10 Enemy 0.032876598 Ally 0.273941411 Ally 0.560821701 Ally 0.798896750 Enemy 0.559524781 Enemy 0.627232231 Enemy 0.864686751 Ally 0.991458997 Enemy 0.699768375 Enemy 0.675523871 0
0.616000000000 0.555555556000 0.621000000000 0.419750000000 0.142319776535
ICPC > Regionals > Asia Pacific > Japan > Japan Domestic Contest > 2024 Japan Domestic Contest I번