結果

問題 No.1267 Stop and Coin Game
ユーザー keymoonkeymoon
提出日時 2020-10-23 22:27:03
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 1,383 bytes
コンパイル時間 4,084 ms
コンパイル使用メモリ 100,224 KB
実行使用メモリ 24,328 KB
最終ジャッジ日時 2023-09-28 16:28:49
合計ジャッジ時間 9,272 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,832 KB
testcase_01 AC 61 ms
21,896 KB
testcase_02 AC 62 ms
21,880 KB
testcase_03 AC 63 ms
23,888 KB
testcase_04 AC 62 ms
23,872 KB
testcase_05 AC 61 ms
21,856 KB
testcase_06 AC 62 ms
21,956 KB
testcase_07 AC 62 ms
19,760 KB
testcase_08 AC 73 ms
21,824 KB
testcase_09 AC 62 ms
21,836 KB
testcase_10 AC 189 ms
22,216 KB
testcase_11 AC 100 ms
21,776 KB
testcase_12 AC 71 ms
21,820 KB
testcase_13 AC 64 ms
21,876 KB
testcase_14 AC 62 ms
19,824 KB
testcase_15 AC 62 ms
21,764 KB
testcase_16 AC 225 ms
24,328 KB
testcase_17 AC 61 ms
23,820 KB
testcase_18 AC 62 ms
23,924 KB
testcase_19 AC 62 ms
23,908 KB
testcase_20 AC 60 ms
19,812 KB
testcase_21 AC 62 ms
23,856 KB
testcase_22 AC 62 ms
23,888 KB
testcase_23 AC 64 ms
21,924 KB
testcase_24 AC 111 ms
21,944 KB
testcase_25 AC 168 ms
21,764 KB
testcase_26 AC 61 ms
23,752 KB
testcase_27 AC 63 ms
19,756 KB
testcase_28 AC 61 ms
21,868 KB
testcase_29 AC 61 ms
21,816 KB
testcase_30 AC 158 ms
22,292 KB
testcase_31 AC 63 ms
21,908 KB
testcase_32 AC 72 ms
21,892 KB
testcase_33 AC 109 ms
23,784 KB
testcase_34 AC 148 ms
21,836 KB
testcase_35 AC 158 ms
22,396 KB
testcase_36 AC 61 ms
21,916 KB
testcase_37 AC 85 ms
23,812 KB
testcase_38 AC 233 ms
22,300 KB
testcase_39 AC 74 ms
21,836 KB
testcase_40 AC 61 ms
21,824 KB
testcase_41 AC 74 ms
21,852 KB
testcase_42 AC 61 ms
21,864 KB
testcase_43 AC 90 ms
21,816 KB
testcase_44 AC 61 ms
21,892 KB
testcase_45 AC 61 ms
21,896 KB
testcase_46 AC 60 ms
21,884 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var nv = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = (int)nv[0];
        var v = nv[1];
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        if (a.Sum() <= v)
        {
            Console.WriteLine("Draw");
            return;
        }
        bool[] canWin = new bool[1 << n];
        for (int i = canWin.Length - 1; i >= 0; i--)
        {
            long sum = 0;
            for (int j = 0; j < n; j++)
            {
                if ((i >> j & 1) != 1) continue;
                sum += a[j];
            }
            if (v < sum)
            {
                //この状態で回ってきたら勝てるか:もう相手が溢れさせているので勝ち
                canWin[i] = true;
                continue;
            }
            for (int j = 0; j < n; j++)
            {
                if ((i >> j & 1) == 1) continue;
                canWin[i] |= !canWin[i | (1 << j)];
            }
        }
        Console.WriteLine(canWin[0] ? "First" : "Second");
    }
}
0