結果
問題 | No.1267 Stop and Coin Game |
ユーザー |
|
提出日時 | 2021-02-20 11:06:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 744 ms / 2,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 161,956 KB |
最終ジャッジ日時 | 2024-09-17 12:57:39 |
合計ジャッジ時間 | 6,688 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
n,v=map(int,input().split())a=list(map(int,input().split()))if sum(a)<=v:print('Draw')exit()memo={}def func(sts,zan):# sts:残りコインを表すビット列# stsの状態で手番がきた時、勝てるならTrueを返す。負けるならFalseを返す。if sts in memo:return memo[sts]if zan<=0:memo[sts]=Falsereturn Falseret=Falsefor i in range(n):if (sts>>i)&1:if zan-a[i]>=0:ret|=not func(sts^(1<<i),zan-a[i])memo[sts]=retreturn retret=func(2**n-1,v)print('First' if ret else 'Second')