結果

問題 No.771 しおり
ユーザー nebukuro09nebukuro09
提出日時 2018-12-18 23:09:07
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 807 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 106,608 KB
実行使用メモリ 35,344 KB
最終ジャッジ日時 2023-09-03 21:44:01
合計ジャッジ時間 6,767 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 269 ms
33,888 KB
testcase_01 AC 30 ms
5,484 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 138 ms
20,112 KB
testcase_26 AC 4 ms
4,376 KB
testcase_27 AC 30 ms
5,468 KB
testcase_28 AC 65 ms
11,072 KB
testcase_29 AC 31 ms
5,472 KB
testcase_30 AC 291 ms
35,344 KB
testcase_31 AC 302 ms
33,516 KB
testcase_32 AC 8 ms
4,500 KB
testcase_33 AC 306 ms
34,784 KB
testcase_34 AC 294 ms
33,220 KB
testcase_35 AC 7 ms
4,380 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 7 ms
4,380 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 130 ms
20,100 KB
testcase_41 AC 295 ms
34,140 KB
testcase_42 AC 281 ms
34,620 KB
testcase_43 AC 32 ms
5,408 KB
testcase_44 AC 293 ms
34,204 KB
testcase_45 AC 271 ms
33,620 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.string;

void main() {
    auto N = readln.chomp.to!int;
    auto AB = N.iota.map!(_ => readln.split.map!(to!int).array).array;
    auto dp = new int[][](1<<N, N);
    foreach (i; 0..(1<<N)) fill(dp[i], 1<<29);
    foreach (i; 0..N) dp[1<<i][i] = 0;

    foreach (mask; 0..(1<<N)) {
        foreach (i; 0..N) {
            if (!(mask & (1 << i))) continue;
            foreach (j; 0..N) {
                if (mask & (1 << j)) continue;
                dp[mask|(1<<j)][j] = min(dp[mask|(1<<j)][j], max(dp[mask][i], AB[i][1] - AB[i][0] + AB[j][0]));
            }
        }
    }

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