結果

問題 No.1267 Stop and Coin Game
ユーザー ああいいああいい
提出日時 2022-02-19 16:14:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,010 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 93,768 KB
最終ジャッジ日時 2023-09-11 20:42:29
合計ジャッジ時間 7,725 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,272 KB
testcase_01 AC 74 ms
71,316 KB
testcase_02 AC 74 ms
71,260 KB
testcase_03 AC 74 ms
71,316 KB
testcase_04 AC 74 ms
71,280 KB
testcase_05 AC 89 ms
76,612 KB
testcase_06 AC 82 ms
76,188 KB
testcase_07 AC 73 ms
71,260 KB
testcase_08 AC 127 ms
79,152 KB
testcase_09 AC 76 ms
76,048 KB
testcase_10 AC 295 ms
93,768 KB
testcase_11 AC 147 ms
81,444 KB
testcase_12 AC 95 ms
77,116 KB
testcase_13 AC 74 ms
71,428 KB
testcase_14 AC 76 ms
71,328 KB
testcase_15 AC 81 ms
76,472 KB
testcase_16 AC 275 ms
93,372 KB
testcase_17 AC 73 ms
71,260 KB
testcase_18 AC 90 ms
76,588 KB
testcase_19 AC 75 ms
71,500 KB
testcase_20 AC 82 ms
76,496 KB
testcase_21 AC 75 ms
71,400 KB
testcase_22 AC 94 ms
76,656 KB
testcase_23 AC 75 ms
71,456 KB
testcase_24 AC 194 ms
85,588 KB
testcase_25 AC 204 ms
85,312 KB
testcase_26 AC 76 ms
71,472 KB
testcase_27 AC 98 ms
77,032 KB
testcase_28 AC 75 ms
71,156 KB
testcase_29 AC 97 ms
76,380 KB
testcase_30 AC 360 ms
93,612 KB
testcase_31 AC 93 ms
76,616 KB
testcase_32 AC 117 ms
78,868 KB
testcase_33 AC 205 ms
85,640 KB
testcase_34 AC 186 ms
85,220 KB
testcase_35 AC 378 ms
93,396 KB
testcase_36 AC 75 ms
71,376 KB
testcase_37 AC 119 ms
78,880 KB
testcase_38 AC 291 ms
93,600 KB
testcase_39 AC 106 ms
77,876 KB
testcase_40 AC 75 ms
71,236 KB
testcase_41 AC 103 ms
77,640 KB
testcase_42 AC 75 ms
71,392 KB
testcase_43 AC 111 ms
79,132 KB
testcase_44 AC 76 ms
71,340 KB
testcase_45 WA -
testcase_46 AC 76 ms
71,496 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