結果

問題 No.1267 Stop and Coin Game
ユーザー ayaoniayaoni
提出日時 2020-10-23 22:41:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 509 ms / 2,000 ms
コード長 951 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 93,632 KB
最終ジャッジ日時 2023-09-28 16:52:48
合計ジャッジ時間 8,849 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,480 KB
testcase_01 AC 84 ms
71,308 KB
testcase_02 AC 79 ms
71,276 KB
testcase_03 AC 82 ms
71,408 KB
testcase_04 AC 80 ms
71,320 KB
testcase_05 AC 90 ms
76,648 KB
testcase_06 AC 87 ms
76,468 KB
testcase_07 AC 82 ms
71,304 KB
testcase_08 AC 126 ms
78,628 KB
testcase_09 AC 86 ms
76,156 KB
testcase_10 AC 465 ms
93,484 KB
testcase_11 AC 160 ms
81,260 KB
testcase_12 AC 106 ms
77,120 KB
testcase_13 AC 81 ms
71,288 KB
testcase_14 AC 81 ms
71,372 KB
testcase_15 AC 91 ms
76,740 KB
testcase_16 AC 494 ms
93,512 KB
testcase_17 AC 80 ms
71,456 KB
testcase_18 AC 97 ms
76,520 KB
testcase_19 AC 79 ms
71,084 KB
testcase_20 AC 87 ms
76,464 KB
testcase_21 AC 80 ms
71,136 KB
testcase_22 AC 95 ms
76,648 KB
testcase_23 AC 79 ms
71,292 KB
testcase_24 AC 197 ms
85,284 KB
testcase_25 AC 253 ms
85,328 KB
testcase_26 AC 79 ms
71,132 KB
testcase_27 AC 94 ms
77,100 KB
testcase_28 AC 80 ms
71,488 KB
testcase_29 AC 96 ms
76,684 KB
testcase_30 AC 429 ms
93,588 KB
testcase_31 AC 99 ms
76,532 KB
testcase_32 AC 116 ms
78,476 KB
testcase_33 AC 191 ms
85,192 KB
testcase_34 AC 231 ms
85,364 KB
testcase_35 AC 425 ms
93,368 KB
testcase_36 AC 80 ms
71,340 KB
testcase_37 AC 136 ms
79,108 KB
testcase_38 AC 509 ms
93,632 KB
testcase_39 AC 125 ms
77,456 KB
testcase_40 AC 83 ms
71,280 KB
testcase_41 AC 122 ms
77,564 KB
testcase_42 AC 80 ms
71,308 KB
testcase_43 AC 134 ms
79,032 KB
testcase_44 AC 80 ms
71,396 KB
testcase_45 AC 79 ms
71,408 KB
testcase_46 AC 79 ms
71,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


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

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

volume = [0]*(2**N)
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)
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