結果

問題 No.1267 Stop and Coin Game
ユーザー H3PO4
提出日時 2022-02-05 14:17:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 970 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 85,040 KB
最終ジャッジ日時 2024-06-11 13:29:50
合計ジャッジ時間 11,426 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

dp = [False] * (1 << N)
for b in range(1 << N):
    s = sum(a for i, a in enumerate(A) if not (b >> i) & 1)
    if V < s:
        dp[b] = True
    for i in range(N):
        if (b >> i) & 1:
            if not dp[b - (1 << i)]:
                dp[b] = True
print("First" if dp[-1] else "Second")
0