結果

問題 No.1151 チャレンジゲーム
ユーザー takakintakakin
提出日時 2020-08-10 22:50:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2024-04-17 06:20:50
合計ジャッジ時間 8,961 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,480 KB
testcase_01 AC 41 ms
52,736 KB
testcase_02 AC 48 ms
61,696 KB
testcase_03 AC 36 ms
51,968 KB
testcase_04 AC 37 ms
52,480 KB
testcase_05 AC 37 ms
51,840 KB
testcase_06 AC 38 ms
51,840 KB
testcase_07 AC 36 ms
52,352 KB
testcase_08 AC 41 ms
52,608 KB
testcase_09 AC 39 ms
52,224 KB
testcase_10 AC 38 ms
52,224 KB
testcase_11 AC 50 ms
61,696 KB
testcase_12 AC 49 ms
62,080 KB
testcase_13 AC 120 ms
77,440 KB
testcase_14 AC 120 ms
76,928 KB
testcase_15 AC 116 ms
76,928 KB
testcase_16 AC 127 ms
76,928 KB
testcase_17 AC 119 ms
77,056 KB
testcase_18 AC 117 ms
77,440 KB
testcase_19 AC 117 ms
77,312 KB
testcase_20 AC 119 ms
77,440 KB
testcase_21 AC 117 ms
77,056 KB
testcase_22 AC 114 ms
76,928 KB
testcase_23 AC 110 ms
77,360 KB
testcase_24 AC 110 ms
77,056 KB
testcase_25 AC 113 ms
76,928 KB
testcase_26 AC 119 ms
77,568 KB
testcase_27 AC 115 ms
77,560 KB
testcase_28 AC 203 ms
78,336 KB
testcase_29 AC 195 ms
78,336 KB
testcase_30 AC 203 ms
78,724 KB
testcase_31 AC 191 ms
78,592 KB
testcase_32 AC 200 ms
78,464 KB
testcase_33 AC 190 ms
78,208 KB
testcase_34 AC 186 ms
78,848 KB
testcase_35 AC 201 ms
78,656 KB
testcase_36 AC 211 ms
78,560 KB
testcase_37 AC 203 ms
78,208 KB
testcase_38 AC 202 ms
78,720 KB
testcase_39 AC 202 ms
78,848 KB
testcase_40 AC 201 ms
78,532 KB
testcase_41 AC 203 ms
78,592 KB
testcase_42 AC 202 ms
78,460 KB
testcase_43 AC 195 ms
78,336 KB
testcase_44 AC 203 ms
78,208 KB
testcase_45 AC 196 ms
78,644 KB
testcase_46 AC 214 ms
78,592 KB
testcase_47 AC 212 ms
78,848 KB
testcase_48 AC 188 ms
78,336 KB
testcase_49 AC 169 ms
78,336 KB
testcase_50 AC 205 ms
78,464 KB
testcase_51 AC 197 ms
78,592 KB
testcase_52 AC 207 ms
78,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
import itertools
n=int(input())
A=[int(i) for i in input().split()]
tot=sum(A)
P=[[0]*(3**n) for _ in range(2)]
for p in itertools.product(range(3),repeat=n):
	index,sen=0,0
	Mitei=[]
	for i in range(n):
		index+=p[i]*3**i
		if p[i]==0:
			sen+=A[i]
		if p[i]==2:
			Mitei.append(i)
	if not Mitei:
		if sen*2>tot:
			for j in range(2):
				P[j][index]=1
		else:
			for j in range(2):
				P[j][index]=0
	else:
		pa0,pa1=0,0
		for m1 in Mitei:
			p0,p1=0,1
			for m2 in Mitei:
				a1,a2=A[m1],A[m2]
				pp0=(P[1][index-2*3**m1]/a1 + P[0][index-3**m2]*(a1-1)/(a1*a2))*a1*a2/(a1+a2-1)
				pp1=(P[0][index-3**m2]/a2 + P[1][index-2*3**m1]*(a2-1)/(a1*a2))*a1*a2/(a1+a2-1)
				if pp1<=p1:
					p0,p1=pp0,pp1
			if p0>=pa0:
				pa0,pa1=p0,p1
		P[0][index]=pa0
		P[1][index]=pa1

print(P[0][-1])

0