結果

問題 No.1267 Stop and Coin Game
ユーザー LyricalMaestroLyricalMaestro
提出日時 2024-01-23 01:27:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 818 ms / 2,000 ms
コード長 1,022 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 83,808 KB
最終ジャッジ日時 2024-01-23 01:27:51
合計ジャッジ時間 8,607 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 65 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 47 ms
64,032 KB
testcase_06 AC 43 ms
59,768 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 94 ms
76,576 KB
testcase_09 AC 43 ms
59,764 KB
testcase_10 AC 539 ms
83,808 KB
testcase_11 AC 216 ms
77,480 KB
testcase_12 AC 91 ms
75,676 KB
testcase_13 AC 37 ms
53,460 KB
testcase_14 AC 37 ms
53,460 KB
testcase_15 AC 49 ms
64,180 KB
testcase_16 AC 712 ms
83,716 KB
testcase_17 AC 37 ms
53,460 KB
testcase_18 AC 61 ms
68,336 KB
testcase_19 AC 40 ms
53,460 KB
testcase_20 AC 43 ms
59,768 KB
testcase_21 AC 37 ms
53,460 KB
testcase_22 AC 61 ms
68,340 KB
testcase_23 AC 37 ms
53,460 KB
testcase_24 AC 186 ms
79,664 KB
testcase_25 AC 441 ms
79,516 KB
testcase_26 AC 37 ms
53,460 KB
testcase_27 AC 50 ms
64,148 KB
testcase_28 AC 37 ms
53,460 KB
testcase_29 AC 58 ms
68,324 KB
testcase_30 AC 420 ms
83,620 KB
testcase_31 AC 69 ms
73,760 KB
testcase_32 AC 75 ms
76,056 KB
testcase_33 AC 167 ms
79,256 KB
testcase_34 AC 349 ms
79,512 KB
testcase_35 AC 402 ms
83,364 KB
testcase_36 AC 37 ms
53,460 KB
testcase_37 AC 141 ms
76,444 KB
testcase_38 AC 818 ms
83,584 KB
testcase_39 AC 109 ms
75,924 KB
testcase_40 AC 37 ms
53,460 KB
testcase_41 AC 111 ms
75,900 KB
testcase_42 AC 37 ms
53,460 KB
testcase_43 AC 136 ms
76,380 KB
testcase_44 AC 37 ms
53,460 KB
testcase_45 AC 37 ms
53,460 KB
testcase_46 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/1267


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

    if V - sum(A) >= 0:
        print("Draw")
        return

    grandies = [-1] * (1 << N)
    for bit in range(1 << N):
        b = ((1 << N) - 1) & (~bit)


        v = 0
        for i in range(N):
            if b & (1 << i):
                v += A[i]

        if V - v < 0:
            continue
        else:
            rest_v = V - v
            grandy_set = set()
            for i in range(N):
                if bit & (1 << i):
                    if rest_v - A[i] < 0:
                        continue

                    bit_ = bit - (1 << i)
                    grandy_set.add(grandies[bit_])
            for i in range(N + 2):
                if i not in grandy_set:
                    grandies[bit] = i
                    break

    if grandies[(1 << N) - 1] == 0:
        print("Second")
    else:
        print("First")











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