結果

問題 No.1267 Stop and Coin Game
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2020-10-23 22:23:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,958 ms / 2,000 ms
コード長 836 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 143,688 KB
最終ジャッジ日時 2023-09-28 16:21:26
合計ジャッジ時間 20,706 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,460 KB
testcase_01 AC 75 ms
71,400 KB
testcase_02 AC 76 ms
71,020 KB
testcase_03 AC 74 ms
71,288 KB
testcase_04 AC 77 ms
71,312 KB
testcase_05 AC 97 ms
76,244 KB
testcase_06 AC 88 ms
76,632 KB
testcase_07 AC 78 ms
70,984 KB
testcase_08 AC 276 ms
89,148 KB
testcase_09 AC 84 ms
76,416 KB
testcase_10 AC 1,908 ms
143,612 KB
testcase_11 AC 484 ms
92,744 KB
testcase_12 AC 143 ms
79,272 KB
testcase_13 AC 80 ms
71,492 KB
testcase_14 AC 77 ms
71,352 KB
testcase_15 AC 94 ms
76,652 KB
testcase_16 AC 1,951 ms
143,472 KB
testcase_17 AC 77 ms
71,380 KB
testcase_18 AC 100 ms
76,472 KB
testcase_19 AC 75 ms
71,376 KB
testcase_20 AC 87 ms
76,764 KB
testcase_21 AC 74 ms
71,172 KB
testcase_22 AC 100 ms
76,844 KB
testcase_23 AC 75 ms
71,472 KB
testcase_24 AC 850 ms
114,884 KB
testcase_25 AC 903 ms
114,984 KB
testcase_26 AC 76 ms
71,332 KB
testcase_27 AC 131 ms
79,548 KB
testcase_28 AC 75 ms
71,220 KB
testcase_29 AC 94 ms
76,704 KB
testcase_30 AC 1,854 ms
143,580 KB
testcase_31 AC 111 ms
77,556 KB
testcase_32 AC 271 ms
88,856 KB
testcase_33 AC 841 ms
114,844 KB
testcase_34 AC 894 ms
114,904 KB
testcase_35 AC 1,833 ms
143,688 KB
testcase_36 AC 76 ms
71,468 KB
testcase_37 AC 290 ms
89,108 KB
testcase_38 AC 1,958 ms
143,592 KB
testcase_39 AC 206 ms
81,812 KB
testcase_40 AC 77 ms
71,320 KB
testcase_41 AC 203 ms
81,816 KB
testcase_42 AC 76 ms
71,440 KB
testcase_43 AC 286 ms
89,144 KB
testcase_44 AC 76 ms
71,184 KB
testcase_45 AC 77 ms
71,380 KB
testcase_46 AC 77 ms
71,464 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()

np = []
for i in range(2**N):
    cnt = 0
    for j in range(N):
        if (1<<j)&i > 0:
            cnt += 1
    np.append( (cnt,i) )
np.sort()
np.reverse()

ans = [None] * (2**N)
for tmp,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