結果
| 問題 |
No.1151 チャレンジゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-08 18:14:56 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 851 bytes |
| コンパイル時間 | 156 ms |
| コンパイル使用メモリ | 82,384 KB |
| 実行使用メモリ | 67,336 KB |
| 最終ジャッジ日時 | 2024-10-01 22:14:17 |
| 合計ジャッジ時間 | 4,652 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 50 |
ソースコード
import numpy as np
N=int(input())
A=[int(x) for x in input().split()]
s=[0]*(1<<N)
for i in range(1<<N):
for j in range(N):
if (i&(1<<j))>0:
s[i]+=A[j]
dp={}
def f(a,b,t):
if (a|b)==(1<<N)-1:
return 1 if 2*s[a]+t>2*s[b] else 0
c=int((a|(b<<N))*t)
if c in dp:
return dp[c]
ret=0
for i in range(N):
na=a|(1<<i)
if (na|b)==(a|b):
continue
e=1
for j in range(N):
nb=b|(1<<j)
if (a|nb)==(a|b):
continue
p,q=A[i],A[j]
vec=np.array([[-f(b,na,t*(-1))/p+1],[-f(a,nb,t)/q+1]])
mat=np.array([[1,-(1-1/q)],[-(1-1/p),1]])
det=(p+q-1)/(p*q)
mat/=det
e=min(e,np.dot(mat,vec)[0][0])
ret=max(ret,e)
dp[c]=ret
return ret
print(f(0,0,-1))