結果

問題 No.1151 チャレンジゲーム
ユーザー takakintakakin
提出日時 2020-08-10 22:50:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 842 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2024-04-17 06:22:04
合計ジャッジ時間 65,105 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 33 ms
10,880 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 29 ms
10,880 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 29 ms
10,752 KB
testcase_08 AC 31 ms
10,880 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 AC 29 ms
10,880 KB
testcase_11 AC 32 ms
10,880 KB
testcase_12 AC 31 ms
10,880 KB
testcase_13 AC 592 ms
12,288 KB
testcase_14 AC 585 ms
12,288 KB
testcase_15 AC 583 ms
12,160 KB
testcase_16 AC 581 ms
12,160 KB
testcase_17 AC 598 ms
12,160 KB
testcase_18 AC 612 ms
12,032 KB
testcase_19 AC 603 ms
12,160 KB
testcase_20 AC 604 ms
12,160 KB
testcase_21 AC 601 ms
12,160 KB
testcase_22 AC 595 ms
12,160 KB
testcase_23 AC 606 ms
12,288 KB
testcase_24 AC 598 ms
12,288 KB
testcase_25 AC 626 ms
12,160 KB
testcase_26 AC 618 ms
12,160 KB
testcase_27 AC 614 ms
12,160 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
testcase_50 TLE -
testcase_51 TLE -
testcase_52 TLE -
権限があれば一括ダウンロードができます

ソースコード

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