結果

問題 No.1267 Stop and Coin Game
ユーザー stnkienstnkien
提出日時 2020-10-23 23:40:37
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 971 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 85,524 KB
最終ジャッジ日時 2023-09-28 18:59:45
合計ジャッジ時間 13,615 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,212 KB
testcase_01 AC 80 ms
71,384 KB
testcase_02 AC 77 ms
71,140 KB
testcase_03 AC 77 ms
71,520 KB
testcase_04 AC 77 ms
71,240 KB
testcase_05 AC 97 ms
76,764 KB
testcase_06 AC 88 ms
76,636 KB
testcase_07 AC 77 ms
71,216 KB
testcase_08 AC 184 ms
78,400 KB
testcase_09 AC 88 ms
76,684 KB
testcase_10 AC 935 ms
85,524 KB
testcase_11 AC 273 ms
79,420 KB
testcase_12 AC 126 ms
77,716 KB
testcase_13 AC 77 ms
71,444 KB
testcase_14 AC 78 ms
71,444 KB
testcase_15 AC 91 ms
76,772 KB
testcase_16 AC 967 ms
85,100 KB
testcase_17 AC 79 ms
71,240 KB
testcase_18 AC 104 ms
76,876 KB
testcase_19 AC 77 ms
71,500 KB
testcase_20 AC 89 ms
76,752 KB
testcase_21 AC 78 ms
71,352 KB
testcase_22 AC 105 ms
76,780 KB
testcase_23 AC 81 ms
71,488 KB
testcase_24 AC 448 ms
81,392 KB
testcase_25 AC 461 ms
81,468 KB
testcase_26 AC 77 ms
70,924 KB
testcase_27 AC 113 ms
77,400 KB
testcase_28 AC 75 ms
71,380 KB
testcase_29 AC 99 ms
76,676 KB
testcase_30 AC 929 ms
85,460 KB
testcase_31 AC 103 ms
76,900 KB
testcase_32 AC 175 ms
78,204 KB
testcase_33 AC 434 ms
81,348 KB
testcase_34 AC 453 ms
81,392 KB
testcase_35 AC 924 ms
85,520 KB
testcase_36 AC 77 ms
71,232 KB
testcase_37 AC 186 ms
78,544 KB
testcase_38 AC 971 ms
85,348 KB
testcase_39 AC 143 ms
77,832 KB
testcase_40 AC 75 ms
71,216 KB
testcase_41 AC 141 ms
77,832 KB
testcase_42 AC 75 ms
71,456 KB
testcase_43 AC 168 ms
78,256 KB
testcase_44 AC 75 ms
71,276 KB
testcase_45 AC 76 ms
71,224 KB
testcase_46 AC 74 ms
71,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, V = map(int, input().split())
*A, = map(int, input().split())

if sum(A) <= V:
    print('Draw')
    exit()

dp = [0]*(1<<N)
for bit in range((1<<N)-1, -1, -1):
    tot = 0
    cnt = bin(bit).count('1')
    res = 1 if cnt & 1 else 2
    for i in range(N):
        if bit >> i & 1:
            tot += A[i]
        else:
            nb = bit|(1<<i)
            if cnt & 1:
                if dp[nb] == 2:
                    res = 2
            else:
                if dp[nb] == 1:
                    res = 1
    if tot > V:
        dp[bit] = 2 if cnt & 1 else 1
    else:
        dp[bit] = res
print('First' if dp[0] == 1 else 'Second')
0