結果

問題 No.771 しおり
ユーザー Shuz*Shuz*
提出日時 2018-12-02 13:19:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 165,308 KB
実行使用メモリ 25,920 KB
最終ジャッジ日時 2023-09-29 12:44:25
合計ジャッジ時間 4,943 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
25,816 KB
testcase_01 AC 18 ms
7,368 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 73 ms
15,868 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 18 ms
7,388 KB
testcase_28 AC 35 ms
9,448 KB
testcase_29 AC 18 ms
7,428 KB
testcase_30 AC 155 ms
25,820 KB
testcase_31 AC 155 ms
25,816 KB
testcase_32 AC 5 ms
4,376 KB
testcase_33 AC 154 ms
25,828 KB
testcase_34 AC 155 ms
25,804 KB
testcase_35 AC 5 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 5 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 73 ms
15,624 KB
testcase_41 AC 155 ms
25,920 KB
testcase_42 AC 154 ms
25,896 KB
testcase_43 AC 18 ms
7,368 KB
testcase_44 AC 154 ms
25,816 KB
testcase_45 AC 155 ms
25,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, _##i = (n); i < _##i; ++i)
#define INF 100000
#define MAX_N 20
int N, new_max, new_bit, A[MAX_N], B[MAX_N], DP[1 << MAX_N][MAX_N];

signed main() {
    cin >> N;
    rep(i, N) cin >> A[i] >> B[i], B[i] -= A[i];
    rep(bit, (1 << N)) rep(i, N) DP[bit][i] = INF;
    rep(bit, (1 << N)) rep(i, N) if (bit & (1 << i)) rep(j, N) if (!(bit & (1 << j))) {
        new_max = DP[bit][i] == INF ? B[i] + A[j] : max(DP[bit][i], B[i] + A[j]);
        new_bit = bit | (1 << j);
        DP[new_bit][j] = min(DP[new_bit][j], new_max);
    }
    cout << *min_element(DP[(1 << N) - 1], DP[(1 << N) - 1] + N) << endl;
}
0