結果

問題 No.771 しおり
ユーザー maimai
提出日時 2018-12-18 23:55:40
言語 cLay
(20231016-1)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 771 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 163,856 KB
実行使用メモリ 23,920 KB
最終ジャッジ日時 2023-09-29 12:45:59
合計ジャッジ時間 5,361 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
23,768 KB
testcase_01 AC 17 ms
9,416 KB
testcase_02 AC 2 ms
5,336 KB
testcase_03 AC 2 ms
5,340 KB
testcase_04 AC 2 ms
5,492 KB
testcase_05 AC 2 ms
5,596 KB
testcase_06 AC 2 ms
5,400 KB
testcase_07 AC 2 ms
5,332 KB
testcase_08 AC 2 ms
5,388 KB
testcase_09 AC 2 ms
5,404 KB
testcase_10 AC 2 ms
5,332 KB
testcase_11 AC 2 ms
5,360 KB
testcase_12 AC 2 ms
5,336 KB
testcase_13 AC 2 ms
5,336 KB
testcase_14 AC 3 ms
5,476 KB
testcase_15 AC 2 ms
5,348 KB
testcase_16 AC 2 ms
5,340 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,404 KB
testcase_19 AC 2 ms
5,344 KB
testcase_20 AC 2 ms
5,328 KB
testcase_21 AC 2 ms
5,352 KB
testcase_22 AC 2 ms
5,332 KB
testcase_23 AC 2 ms
5,348 KB
testcase_24 AC 2 ms
5,348 KB
testcase_25 AC 67 ms
15,564 KB
testcase_26 AC 4 ms
5,696 KB
testcase_27 AC 17 ms
9,648 KB
testcase_28 AC 32 ms
11,480 KB
testcase_29 AC 17 ms
9,448 KB
testcase_30 AC 137 ms
23,916 KB
testcase_31 AC 137 ms
23,912 KB
testcase_32 AC 5 ms
5,940 KB
testcase_33 AC 137 ms
23,920 KB
testcase_34 AC 137 ms
23,768 KB
testcase_35 AC 6 ms
5,924 KB
testcase_36 AC 2 ms
5,480 KB
testcase_37 AC 2 ms
5,504 KB
testcase_38 AC 5 ms
5,920 KB
testcase_39 AC 3 ms
5,476 KB
testcase_40 AC 67 ms
15,572 KB
testcase_41 AC 137 ms
23,780 KB
testcase_42 AC 137 ms
23,756 KB
testcase_43 AC 17 ms
9,460 KB
testcase_44 AC 137 ms
23,768 KB
testcase_45 AC 137 ms
23,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

int N;
int A[1000][2];
int dp[1<<18][18];

inline int dist(int i, int j) {
    return A[i][1] - A[i][0] + A[j][0];
}

{
    rd(N);
    REP(i, N) {
        int a, b; rd(a, b);
        A[i][0] = a;
        A[i][1] = b;
    }
    
    fill(dp[1], dp[1<<N], int(1e9));
    
    REP(i, N) {
        dp[0][i] = 0;
        dp[1<<i][i] = 0;
    }
    
    REP(b, 1, 1 << N) {
        REP(i, N) {
            if (~b & (1 << i)) continue;
            REP(j, N) {
                if (b & (1 << j)) continue; 
                dp[b | (1 << j)][j] = min(dp[b | (1 << j)][j],
                    max(dp[b][i], dist(i, j))
                );
            }
        }
    }
    
    int best = 1e9;
    REP(i, N){
        best = min(best, dp[(1<<N)-1][i]);
    }
    
    wt(best);
    
}
0