結果

問題 No.1267 Stop and Coin Game
ユーザー ntuda
提出日時 2025-02-03 21:44:14
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 566 bytes
コンパイル時間 642 ms
コンパイル使用メモリ 82,328 KB
実行使用メモリ 292,064 KB
最終ジャッジ日時 2025-02-03 21:44:38
合計ジャッジ時間 19,628 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

N,V = map(int,input().split())
A = list(map(int,input().split()))
if sum(A) <= V:
    print("Draw")
    exit()

allb = (1<<N)-1
X = [0] * (allb + 1)
for i in range(allb + 1):
    x = i ^ allb
    t1 = V
    for j in range(N):
        if x & (1<<j):
            t1 -= A[j]
    X[i] = t1
from functools import lru_cache
@lru_cache(maxsize=1050000)
def f(x):
    if X[x] < 0:
        return True
    ret = False
    for i in range(N):
        if x & (1<<i):
            ret |= not(f(x ^ (1<<i)))
    return ret

if f(allb):
    print("First")
else:
    print("Second")
0