結果

問題 No.771 しおり
ユーザー pekempeypekempey
提出日時 2018-12-19 06:24:06
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 29,512 KB
実行使用メモリ 20,332 KB
最終ジャッジ日時 2023-09-29 12:46:56
合計ジャッジ時間 3,428 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
20,220 KB
testcase_01 AC 15 ms
5,980 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 0 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 0 ms
4,380 KB
testcase_20 AC 0 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 64 ms
12,116 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 15 ms
5,864 KB
testcase_28 AC 30 ms
7,920 KB
testcase_29 AC 15 ms
5,852 KB
testcase_30 AC 134 ms
20,232 KB
testcase_31 AC 135 ms
20,192 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 AC 135 ms
20,212 KB
testcase_34 AC 134 ms
20,200 KB
testcase_35 AC 4 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 3 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 63 ms
12,124 KB
testcase_41 AC 135 ms
20,200 KB
testcase_42 AC 134 ms
20,252 KB
testcase_43 AC 15 ms
5,880 KB
testcase_44 AC 136 ms
20,332 KB
testcase_45 AC 134 ms
20,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int n, a[1000], b[1000];
int dp[1 << 18][18];

int min(int x, int y) {
    return x < y ? x : y;
}

int max(int x, int y) {
    return x > y ? x : y;
}

int main(void) {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &a[i], &b[i]);
    }
    for (int i = 0; i < 1 << n; i++) {
        for (int j = 0; j < n; j++) {
            dp[i][j] = 2147483647;
            if (i & 1 << j) {
                for (int k = 0; k < n; k++) if (i & 1 << k) {
                    dp[i][j] = min(dp[i][j], max(dp[i ^ 1 << j][k], a[j] + b[k] - a[k]));
                }
                if ((i & i - 1) == 0) {
                    dp[i][j] = 0;
                }
            }
        }
    }
    int ans = 2147483647;
    for (int i = 0; i < n; i++) {
        ans = min(ans, dp[(1 << n) - 1][i]);
    }
    printf("%d\n", ans);
    return 0;
}

0