結果

問題 No.519 アイドルユニット
ユーザー nebukuro09nebukuro09
提出日時 2017-06-10 15:28:47
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 56 ms / 1,000 ms
コード長 789 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 107,856 KB
実行使用メモリ 68,652 KB
最終ジャッジ日時 2023-09-03 14:13:01
合計ジャッジ時間 2,405 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
68,652 KB
testcase_01 AC 55 ms
68,560 KB
testcase_02 AC 16 ms
19,760 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 3 ms
5,140 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 3 ms
5,368 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 3 ms
4,384 KB
testcase_21 AC 3 ms
4,384 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 5 ms
5,776 KB
testcase_25 AC 6 ms
7,404 KB
testcase_26 AC 6 ms
8,264 KB
testcase_27 AC 6 ms
8,472 KB
testcase_28 AC 5 ms
7,408 KB
testcase_29 AC 55 ms
68,604 KB
testcase_30 AC 56 ms
68,612 KB
testcase_31 AC 56 ms
68,644 KB
testcase_32 AC 56 ms
68,468 KB
testcase_33 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.stdio;



void main() {
    auto N = readln.chomp.to!int;
    auto F = N.iota.map!(_ => readln.split.map!(to!int).array).array;

    auto dp = new int[](1 << N);
    fill(dp, -1);
    dp[0] = 0;

    for (int mask = 0; mask < (1 << N); mask++) {
        if (dp[mask] < 0) continue;
        int i = bsf(~mask);
        foreach (j; i+1..N) {
            if (!(mask & (1 << j))) {
                dp[mask | (1 << i) | (1 << j)] = max(dp[mask | (1 << i) | (1 << j)],
                                                     dp[mask] + F[i][j]);
            }
        }
    }

    dp[(1 << N) - 1].writeln;
}
0