結果

問題 No.1267 Stop and Coin Game
ユーザー ああいいああいい
提出日時 2022-02-19 16:15:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 1,011 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 93,740 KB
最終ジャッジ日時 2023-09-11 20:42:38
合計ジャッジ時間 7,850 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,288 KB
testcase_01 AC 74 ms
71,540 KB
testcase_02 AC 78 ms
71,276 KB
testcase_03 AC 75 ms
71,624 KB
testcase_04 AC 74 ms
71,256 KB
testcase_05 AC 88 ms
76,500 KB
testcase_06 AC 85 ms
76,272 KB
testcase_07 AC 75 ms
71,312 KB
testcase_08 AC 127 ms
79,144 KB
testcase_09 AC 80 ms
75,976 KB
testcase_10 AC 292 ms
93,504 KB
testcase_11 AC 146 ms
81,220 KB
testcase_12 AC 95 ms
77,284 KB
testcase_13 AC 75 ms
71,268 KB
testcase_14 AC 75 ms
71,264 KB
testcase_15 AC 83 ms
76,428 KB
testcase_16 AC 275 ms
93,596 KB
testcase_17 AC 75 ms
71,372 KB
testcase_18 AC 91 ms
76,528 KB
testcase_19 AC 75 ms
71,268 KB
testcase_20 AC 81 ms
76,660 KB
testcase_21 AC 74 ms
71,272 KB
testcase_22 AC 92 ms
76,656 KB
testcase_23 AC 74 ms
71,416 KB
testcase_24 AC 191 ms
85,204 KB
testcase_25 AC 202 ms
85,596 KB
testcase_26 AC 74 ms
71,400 KB
testcase_27 AC 96 ms
77,072 KB
testcase_28 AC 74 ms
71,460 KB
testcase_29 AC 94 ms
76,788 KB
testcase_30 AC 359 ms
93,504 KB
testcase_31 AC 94 ms
76,772 KB
testcase_32 AC 118 ms
78,624 KB
testcase_33 AC 203 ms
85,332 KB
testcase_34 AC 183 ms
85,320 KB
testcase_35 AC 373 ms
93,212 KB
testcase_36 AC 74 ms
71,336 KB
testcase_37 AC 125 ms
78,896 KB
testcase_38 AC 290 ms
93,740 KB
testcase_39 AC 104 ms
77,624 KB
testcase_40 AC 74 ms
71,340 KB
testcase_41 AC 103 ms
77,416 KB
testcase_42 AC 74 ms
71,532 KB
testcase_43 AC 110 ms
79,064 KB
testcase_44 AC 76 ms
71,272 KB
testcase_45 AC 75 ms
71,540 KB
testcase_46 AC 75 ms
71,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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")
0