結果

問題 No.1267 Stop and Coin Game
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2020-10-23 22:28:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,275 ms / 2,000 ms
コード長 885 bytes
コンパイル時間 1,188 ms
コンパイル使用メモリ 86,740 KB
実行使用メモリ 129,700 KB
最終ジャッジ日時 2023-09-28 16:32:12
合計ジャッジ時間 14,435 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,256 KB
testcase_01 AC 77 ms
71,172 KB
testcase_02 AC 79 ms
70,960 KB
testcase_03 AC 77 ms
71,340 KB
testcase_04 AC 78 ms
71,176 KB
testcase_05 AC 91 ms
76,476 KB
testcase_06 AC 92 ms
76,164 KB
testcase_07 AC 79 ms
71,236 KB
testcase_08 AC 153 ms
87,004 KB
testcase_09 AC 87 ms
76,388 KB
testcase_10 AC 1,173 ms
129,504 KB
testcase_11 AC 255 ms
98,616 KB
testcase_12 AC 117 ms
78,932 KB
testcase_13 AC 80 ms
71,080 KB
testcase_14 AC 79 ms
71,188 KB
testcase_15 AC 93 ms
76,260 KB
testcase_16 AC 1,275 ms
129,700 KB
testcase_17 AC 79 ms
71,440 KB
testcase_18 AC 100 ms
76,460 KB
testcase_19 AC 78 ms
71,444 KB
testcase_20 AC 87 ms
76,352 KB
testcase_21 AC 76 ms
71,096 KB
testcase_22 AC 102 ms
76,320 KB
testcase_23 AC 78 ms
71,100 KB
testcase_24 AC 362 ms
110,344 KB
testcase_25 AC 447 ms
110,412 KB
testcase_26 AC 77 ms
71,300 KB
testcase_27 AC 102 ms
78,344 KB
testcase_28 AC 78 ms
71,392 KB
testcase_29 AC 97 ms
76,460 KB
testcase_30 AC 1,100 ms
129,340 KB
testcase_31 AC 101 ms
76,456 KB
testcase_32 AC 145 ms
87,004 KB
testcase_33 AC 370 ms
110,144 KB
testcase_34 AC 434 ms
110,412 KB
testcase_35 AC 1,058 ms
129,348 KB
testcase_36 AC 75 ms
71,312 KB
testcase_37 AC 165 ms
86,612 KB
testcase_38 AC 1,238 ms
129,520 KB
testcase_39 AC 143 ms
81,272 KB
testcase_40 AC 76 ms
71,336 KB
testcase_41 AC 144 ms
81,168 KB
testcase_42 AC 77 ms
71,432 KB
testcase_43 AC 164 ms
87,004 KB
testcase_44 AC 76 ms
71,396 KB
testcase_45 AC 77 ms
71,184 KB
testcase_46 AC 75 ms
71,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

ゲームdfs?
2^20

1を勝ち、0を負けとする
1つでも0があったら勝ち

"""

from sys import stdin
import sys
N,V = map(int,stdin.readline().split())
A = list(map(int,stdin.readline().split()))

if sum(A) <= V:
    print ("Draw")
    sys.exit()

ans = [-1] * (2**N)
ans[0] = None
np = [0]
qi = 0

while qi < len(np):
    for j in range(N):
        nex = np[qi] | (1<<j)
        if ans[nex] == -1:
            ans[nex] = None
            np.append(nex)
    qi += 1

np.reverse()


for i in np:

    s = 0
    for j in range(N):
        if (1<<j)&i > 0:
            s += A[j]
    if s > V:
        ans[i] = 1
    else:
        for j in range(N):
            if (1<<j)&i == 0 and ans[(1<<j)|i] == 0:
                ans[i] = 1
                break
        else:
            ans[i] = 0

if ans[0] == 0:
    print ("Second")
else:
    print ("First")
                
0