結果

問題 No.1267 Stop and Coin Game
コンテスト
ユーザー rlangevin
提出日時 2023-02-07 22:52:38
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 503 ms / 2,000 ms
コード長 480 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,364 ms
コンパイル使用メモリ 84,944 KB
実行使用メモリ 89,088 KB
最終ジャッジ日時 2026-03-27 01:58:28
合計ジャッジ時間 11,723 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, V = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) <= V:
    print("Draw")
    exit()
    
N2 = 1 << N
dp = [1] * 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] &= dp[s | (1 << i)]
    dp[s] = 1 - dp[s]

ans = 0
print("First") if dp[0] else print("Second")
0