結果

問題 No.1267 Stop and Coin Game
ユーザー 👑 Kazun
提出日時 2020-10-23 22:50:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 511 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 92,876 KB
最終ジャッジ日時 2024-07-21 11:57:30
合計ジャッジ時間 6,724 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(x):
    if T[x]!=None:
        return T[x]

    for j in range(N):
        if x&(1<<j)==0 and S[x|(1<<j)]<=V:
            if not f(x|(1<<j)):
                T[x]=True
                return True

    T[x]=False
    return False

N,V=map(int,input().split())
A=list(map(int,input().split()))

if sum(A)<=V:
    print("Draw")
    exit()

S=[0]*(1<<N)
for b in range(1<<N):
    a=b
    x=0
    for k in range(N):
        if b&1:
            x+=A[k]
        b>>=1
    S[a]=x

T=[None]*(1<<N)

if f(0):
    print("First")
else:
    print("Second")
0