結果

問題 No.1267 Stop and Coin Game
ユーザー nebukuro09nebukuro09
提出日時 2020-10-23 23:23:32
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 831 bytes
コンパイル時間 2,292 ms
コンパイル使用メモリ 114,892 KB
実行使用メモリ 7,900 KB
最終ジャッジ日時 2023-09-04 10:52:34
合計ジャッジ時間 3,226 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 45 ms
7,384 KB
testcase_11 AC 19 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 93 ms
7,440 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 5 ms
4,736 KB
testcase_25 AC 71 ms
5,140 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 3 ms
6,892 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
5,068 KB
testcase_34 AC 51 ms
5,168 KB
testcase_35 AC 4 ms
7,132 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 13 ms
4,908 KB
testcase_38 AC 105 ms
7,900 KB
testcase_39 AC 7 ms
4,376 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 8 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 15 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib, std.datetime;


void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0].to!int;
    auto V = s[1];
    auto A = readln.split.map!(to!long).array;

    if (A.sum <= V) {
        writeln("Draw");
        return;
    }

    auto mem = new int[](1 << N);
    mem[] = -1;

    int rec(int mask, long vol) {
        if (mem[mask] != -1) return mem[mask];
        if (vol > V) return mem[mask] = 1;
        mem[mask] = 0;
        foreach (i; 0..N) if (!(mask & (1 << i))) {
            mem[mask] |= !rec(mask | (1 << i), vol + A[i]);
        }
        return mem[mask];
    }


    writeln(rec(0, 0) ? "First" : "Second");
}
0