結果

問題 No.771 しおり
ユーザー Shuz*Shuz*
提出日時 2018-12-02 12:45:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 166,212 KB
実行使用メモリ 4,748 KB
最終ジャッジ日時 2023-09-13 20:48:51
合計ジャッジ時間 3,134 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 23 ms
4,624 KB
testcase_02 AC 2 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,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 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 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 23 ms
4,668 KB
testcase_28 WA -
testcase_29 AC 23 ms
4,748 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 6 ms
4,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 6 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 6 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 23 ms
4,708 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (unsigned short i = 0, _##i = (n); i < _##i; ++i)
#define INF 50000
#define MAX_N 20
unsigned short 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 & (1LL << i))) continue;
            rep(j, N) {
                if (bit & (1LL << j)) continue;
                new_max = DP[bit][i] == INF ? B[i] + A[j] : max(int(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