Logo
(追記) (追記ここまで)

32054번 - All Survived? 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 (추가 시간 없음) 1024 MB311100.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.

  • If the balloon of the attacker has already been popped, the attacker is dead and this phase is skipped without any actions.
  • If all of the opposing team members are dead, the phase is skipped as well.
  • Otherwise, one of the opposing players alive is chosen as the target to attack. The choice may be based on the results of previous actions. The attack succeeds with the hit probability of the attacker, regardless of the target. When the attack succeeds, the balloon of the target is popped, and the target is killed.

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.

제한

예제 입력 1

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

예제 출력 1

0.616000000000
0.555555556000
0.621000000000
0.419750000000
0.142319776535

힌트

출처

ICPC > Regionals > Asia Pacific > Japan > Japan Domestic Contest > 2024 Japan Domestic Contest I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /