結果

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

ソースコード

diff #

def f(s, total):
    if total > V:
        dp[s] = 0
        return 0
    if dp[s] != -1:
        return dp[s]
    R = 0
    for i in range(N):
        if (1<<i) & s:
            continue
        c = f((1<<i)|s, total+X[i])
        R = R|c
    dp[s] = (not R)
    return not R


N, V = map(int, input().split())
X = list(map(int, input().split()))
dp = [-1]*(2**N)
if sum(X) <= V:
    print("Draw")
elif f(0, 0):
    print("Second")
else:
    print("First")
0