結果

問題 No.1267 Stop and Coin Game
ユーザー SPD_9X2
提出日時 2020-10-23 22:23:13
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 836 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 142,928 KB
最終ジャッジ日時 2024-07-21 11:05:25
合計ジャッジ時間 18,367 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

ゲームdfs?
2^20

1を勝ち、0を負けとする
1つでも0があったら勝ち

"""

from sys import stdin
import sys
N,V = map(int,stdin.readline().split())
A = list(map(int,stdin.readline().split()))

if sum(A) <= V:
    print ("Draw")
    sys.exit()

np = []
for i in range(2**N):
    cnt = 0
    for j in range(N):
        if (1<<j)&i > 0:
            cnt += 1
    np.append( (cnt,i) )
np.sort()
np.reverse()

ans = [None] * (2**N)
for tmp,i in np:

    s = 0
    for j in range(N):
        if (1<<j)&i > 0:
            s += A[j]
    if s > V:
        ans[i] = 1
    else:
        for j in range(N):
            if (1<<j)&i == 0 and ans[(1<<j)|i] == 0:
                ans[i] = 1
                break
        else:
            ans[i] = 0

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