結果
| 問題 |
No.1267 Stop and Coin Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-19 16:14:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,010 bytes |
| コンパイル時間 | 175 ms |
| コンパイル使用メモリ | 82,512 KB |
| 実行使用メモリ | 92,416 KB |
| 最終ジャッジ日時 | 2024-06-29 10:27:00 |
| 合計ジャッジ時間 | 5,449 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 42 WA * 1 |
ソースコード
N,V = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
import sys
if S < V:
print("Draw")
exit()
sys.setrecursionlimit(10 ** 8 )
dat = [0] * (1 << N)
for bit in range(1,1 << N):
for i in range(N):
mask = 1 << i
if bit & mask:
dat[bit] = A[i] + dat[bit ^ mask]
break
"""
from functools import lru_cache
@lru_cache
def calc(S = 0):
#flag = S.count('1')
for i in range(N):
mask = 1 << i
if S & mask:continue
if dat[S | mask] > V:continue
a = calc(S | mask)
if a == False:return True
return False
"""
grundy = [0] * (1 << N)
for bit in range((1 << N)-1,-1,-1):
flag = False
for i in range(N):
mask = 1 << i
if bit & mask:continue
if dat[bit | mask] > V:continue
if grundy[bit | mask] == 0:
flag = True
break
if flag:
grundy[bit] = 1
else:
grundy[bit] = 0
print('First' if grundy[0] else "Second")