結果
| 問題 | No.771 しおり | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-12-18 23:09:07 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 337 ms / 2,000 ms | 
| コード長 | 807 bytes | 
| コンパイル時間 | 771 ms | 
| コンパイル使用メモリ | 118,528 KB | 
| 実行使用メモリ | 32,256 KB | 
| 最終ジャッジ日時 | 2024-06-13 02:23:22 | 
| 合計ジャッジ時間 | 6,104 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 43 | 
ソースコード
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;
}
            
            
            
        