結果

問題 No.1267 Stop and Coin Game
ユーザー stnkienstnkien
提出日時 2020-10-24 00:32:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 84,172 KB
最終ジャッジ日時 2024-07-21 14:24:17
合計ジャッジ時間 6,133 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

dp = [0]*(1<<N)
for bit in range((1<<N)-1, -1, -1):
    tot = 0
    res = 0
    for i in range(N):
        if bit >> i & 1:
            tot += A[i]
        else:
            nb = bit|(1<<i)
            if dp[nb] == 0:
                res = 1
    if tot > V:
        dp[bit] = 1
    else:
        dp[bit] = res
print('First' if dp[0] == 1 else 'Second')
0