結果

問題 No.1267 Stop and Coin Game
ユーザー AEn
提出日時 2022-11-28 22:56:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 655 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 92,636 KB
最終ジャッジ日時 2024-10-06 00:30:34
合計ジャッジ時間 7,604 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if sum(A)<=V:
    print('Draw')
else:
    dp = [False]*(1<<N)
    for i in range(1<<N):
        sm = 0
        for j in range(N):
            if not i&(1<<j):
                sm += A[j]
        if sm>V:
            continue
        for j in range(N):
            if i&(1<<j) and V-sm>=A[j]:
                dp[i] |= dp[i^(1<<j)]^1
    print('First' if dp[-1] else 'Second')

0