結果

問題 No.1267 Stop and Coin Game
ユーザー tcltktcltk
提出日時 2021-05-18 15:09:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,471 ms / 2,000 ms
コード長 996 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 98,620 KB
最終ジャッジ日時 2024-04-17 04:35:50
合計ジャッジ時間 17,564 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
86,728 KB
testcase_01 AC 127 ms
86,528 KB
testcase_02 AC 125 ms
86,872 KB
testcase_03 AC 136 ms
86,912 KB
testcase_04 AC 133 ms
87,168 KB
testcase_05 AC 198 ms
90,240 KB
testcase_06 AC 145 ms
89,160 KB
testcase_07 AC 126 ms
86,880 KB
testcase_08 AC 298 ms
91,520 KB
testcase_09 AC 133 ms
87,168 KB
testcase_10 AC 1,262 ms
98,560 KB
testcase_11 AC 491 ms
92,280 KB
testcase_12 AC 250 ms
90,496 KB
testcase_13 AC 127 ms
86,540 KB
testcase_14 AC 127 ms
86,644 KB
testcase_15 AC 147 ms
89,056 KB
testcase_16 AC 1,339 ms
98,620 KB
testcase_17 AC 124 ms
86,916 KB
testcase_18 AC 205 ms
90,216 KB
testcase_19 AC 136 ms
86,612 KB
testcase_20 AC 146 ms
89,216 KB
testcase_21 AC 127 ms
86,736 KB
testcase_22 AC 198 ms
90,344 KB
testcase_23 AC 126 ms
86,784 KB
testcase_24 AC 564 ms
94,868 KB
testcase_25 AC 766 ms
95,232 KB
testcase_26 AC 126 ms
87,040 KB
testcase_27 AC 186 ms
89,912 KB
testcase_28 AC 125 ms
87,008 KB
testcase_29 AC 183 ms
89,600 KB
testcase_30 AC 1,159 ms
98,244 KB
testcase_31 AC 235 ms
90,752 KB
testcase_32 AC 258 ms
91,136 KB
testcase_33 AC 505 ms
94,080 KB
testcase_34 AC 686 ms
94,848 KB
testcase_35 AC 1,084 ms
97,976 KB
testcase_36 AC 125 ms
87,040 KB
testcase_37 AC 356 ms
91,752 KB
testcase_38 AC 1,471 ms
98,560 KB
testcase_39 AC 288 ms
90,700 KB
testcase_40 AC 127 ms
86,884 KB
testcase_41 AC 295 ms
91,136 KB
testcase_42 AC 128 ms
86,912 KB
testcase_43 AC 341 ms
91,264 KB
testcase_44 AC 126 ms
86,912 KB
testcase_45 AC 124 ms
86,912 KB
testcase_46 AC 123 ms
86,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """3 5
# 5 1 1
# """
# sys.stdin = io.StringIO(_INPUT)


def main():
    N, V = map(int, input().split())
    A = list(map(int, input().split()))

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

    dp = [None] * (1<<N)
    for s in range(1<<N):
        cap = sum(A[i] for i in range(N) if s & (1<<i))
        dp[s] = (cap <= V)

    for s in reversed(range(1<<N)):
        if dp[s]:
            # 自分が何を選んでも、次に相手は勝つ。ということは、自分は負け
            if any(dp[s | (1<<j)] for j in range(N) if s & (1<<j) == 0):
                dp[s] = False

    if dp[0]:
        print('Second')
    else:
        print('First')

if __name__ == '__main__':
    main()
0