結果

問題 No.1267 Stop and Coin Game
コンテスト
ユーザー aaaaaaaaaa2230
提出日時 2020-10-31 17:41:48
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 470 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 277 ms
コンパイル使用メモリ 85,288 KB
実行使用メモリ 89,268 KB
最終ジャッジ日時 2026-04-03 07:33:06
合計ジャッジ時間 4,368 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge2_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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()

dp = [1]*(1<<n)
for i in range(2**n-1,-1,-1):
    s = 0
    for j in range(n):
        if i >> j & 1:
            s += a[j]
    if s > v:
        continue
    check = 0
    for j in range(n):
        if i >> j & 1:
            continue
        if dp[i|1<<j] == 0:
            check = 1
    dp[i] = check
if dp[0]:
    print("First")
else:
    print("Second")
0