結果

問題 No.1267 Stop and Coin Game
ユーザー rlangevin
提出日時 2023-02-07 22:43:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 84,144 KB
最終ジャッジ日時 2024-07-05 16:41:45
合計ジャッジ時間 5,950 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

N, V = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) <= V:
    print("Draw")
    exit()
    
N2 = 1 << N
dp = [0] * N2
for s in range(N2 - 1, -1, -1):
    vol = V
    for i in range(N):
        if (s >> i) & 1:
            vol -= A[i]
    if vol < 0:
        continue
    for i in range(N):
        if (s >> i) & 1 == 0 and vol - A[i] >= 0:
            dp[s] ^= 1 - dp[s | (1 << i)]

ans = 0
for i in range(N):
    ans |= dp[1 << i]
print("First") if ans else print("Second")
0