結果

問題 No.1267 Stop and Coin Game
ユーザー ayaoniayaoni
提出日時 2020-10-24 00:31:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 507 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 1,116 ms
コンパイル使用メモリ 86,732 KB
実行使用メモリ 93,400 KB
最終ジャッジ日時 2023-09-28 19:41:04
合計ジャッジ時間 9,020 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,024 KB
testcase_01 AC 80 ms
71,260 KB
testcase_02 AC 85 ms
71,156 KB
testcase_03 AC 80 ms
71,108 KB
testcase_04 AC 80 ms
71,076 KB
testcase_05 AC 90 ms
76,300 KB
testcase_06 AC 88 ms
76,320 KB
testcase_07 AC 83 ms
71,352 KB
testcase_08 AC 125 ms
78,568 KB
testcase_09 AC 88 ms
76,208 KB
testcase_10 AC 482 ms
93,356 KB
testcase_11 AC 159 ms
80,884 KB
testcase_12 AC 103 ms
76,844 KB
testcase_13 AC 78 ms
71,156 KB
testcase_14 AC 79 ms
71,176 KB
testcase_15 AC 89 ms
76,312 KB
testcase_16 AC 507 ms
93,324 KB
testcase_17 AC 80 ms
71,004 KB
testcase_18 AC 95 ms
76,160 KB
testcase_19 AC 79 ms
71,168 KB
testcase_20 AC 86 ms
76,156 KB
testcase_21 AC 80 ms
71,384 KB
testcase_22 AC 95 ms
76,420 KB
testcase_23 AC 80 ms
71,360 KB
testcase_24 AC 194 ms
85,216 KB
testcase_25 AC 255 ms
85,212 KB
testcase_26 AC 78 ms
71,216 KB
testcase_27 AC 91 ms
76,804 KB
testcase_28 AC 78 ms
70,968 KB
testcase_29 AC 92 ms
76,272 KB
testcase_30 AC 432 ms
93,340 KB
testcase_31 AC 97 ms
76,448 KB
testcase_32 AC 116 ms
78,344 KB
testcase_33 AC 190 ms
85,056 KB
testcase_34 AC 231 ms
85,196 KB
testcase_35 AC 417 ms
93,176 KB
testcase_36 AC 80 ms
71,160 KB
testcase_37 AC 136 ms
78,696 KB
testcase_38 AC 501 ms
93,400 KB
testcase_39 AC 124 ms
77,404 KB
testcase_40 AC 82 ms
71,268 KB
testcase_41 AC 120 ms
77,384 KB
testcase_42 AC 81 ms
71,160 KB
testcase_43 AC 134 ms
79,080 KB
testcase_44 AC 80 ms
71,120 KB
testcase_45 AC 81 ms
70,964 KB
testcase_46 AC 80 ms
71,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))


N,V = MI()
A = LI()
s = sum(A)

if s <= V:
    print('Draw')
    exit()

volume = [0]*(2**N)  # iに対応する硬貨の体積の総和
for i in range(2**N):
    x = 0
    for j in range(N):
        if (i>>j) & 1:
            x += A[j]
    volume[i] = x

dp = [-1]*(2**N)  # dp[i] = iを未使用の硬貨の集合とするとき、先手必勝か否か
for i in range(2**N):
    if s-volume[i] > V:
        continue
    for j in range(N):
        if (i >> j) & 1:
            if dp[i ^ (1 << j)] == 0:
                dp[i] = 1
                break
    else:
        dp[i] = 0

print('First' if dp[-1] == 1 else 'Second')
0