結果
問題 |
No.1151 チャレンジゲーム
|
ユーザー |
|
提出日時 | 2020-08-08 18:13:23 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 851 bytes |
コンパイル時間 | 261 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 49,052 KB |
最終ジャッジ日時 | 2024-10-01 22:12:10 |
合計ジャッジ時間 | 13,289 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 6 WA * 4 TLE * 1 -- * 39 |
ソースコード
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))