結果

問題 No.1267 Stop and Coin Game
コンテスト
ユーザー NatsubiSogan
提出日時 2020-10-24 00:59:35
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 460 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 528 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 31,364 KB
最終ジャッジ日時 2026-04-03 04:59:44
合計ジャッジ時間 9,202 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 TLE * 1 -- * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n, v = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) <= v:
    exit(print("Draw"))
dp = [-1] * (1 << n)
def dfs(S, t):
    if t > v:
        dp[S] = 0
        return 0
    if dp[S] != -1:
        return dp[S]
    res = 0
    for i in range(n):
        if (1 << i) & S:
            continue
        res |= dfs((1 << i) | S, t + a[i])
    dp[S] = (not res)
    return (not res)
if dfs(0, 0):
    print("Second")
else:
    print("First")
0