結果

問題 No.771 しおり
ユーザー Shuz*Shuz*
提出日時 2018-12-02 13:12:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 1,499 ms
コンパイル使用メモリ 166,044 KB
実行使用メモリ 26,128 KB
最終ジャッジ日時 2023-09-29 12:43:57
合計ジャッジ時間 5,931 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 257 ms
25,904 KB
testcase_01 AC 26 ms
7,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 118 ms
15,612 KB
testcase_26 AC 4 ms
4,376 KB
testcase_27 AC 25 ms
7,388 KB
testcase_28 AC 56 ms
9,624 KB
testcase_29 AC 25 ms
7,376 KB
testcase_30 AC 259 ms
25,828 KB
testcase_31 AC 257 ms
25,952 KB
testcase_32 AC 6 ms
4,380 KB
testcase_33 AC 258 ms
26,128 KB
testcase_34 AC 256 ms
25,888 KB
testcase_35 AC 7 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 6 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 118 ms
15,624 KB
testcase_41 AC 257 ms
25,844 KB
testcase_42 AC 256 ms
25,820 KB
testcase_43 AC 26 ms
7,580 KB
testcase_44 AC 257 ms
25,816 KB
testcase_45 AC 258 ms
25,900 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) {
            rep(j, N) {
                if (bit & (1 << i) && !(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