結果

問題 No.771 しおり
ユーザー ei1333333ei1333333
提出日時 2018-12-18 23:17:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 249 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 198,948 KB
実行使用メモリ 22,012 KB
最終ジャッジ日時 2023-09-29 12:46:12
合計ジャッジ時間 5,960 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 249 ms
21,732 KB
testcase_01 AC 26 ms
21,760 KB
testcase_02 AC 6 ms
21,724 KB
testcase_03 AC 6 ms
21,720 KB
testcase_04 AC 5 ms
21,784 KB
testcase_05 AC 5 ms
21,972 KB
testcase_06 AC 5 ms
21,844 KB
testcase_07 AC 5 ms
21,872 KB
testcase_08 AC 6 ms
21,788 KB
testcase_09 AC 5 ms
21,724 KB
testcase_10 AC 5 ms
21,712 KB
testcase_11 AC 4 ms
21,764 KB
testcase_12 AC 6 ms
21,832 KB
testcase_13 AC 5 ms
21,976 KB
testcase_14 AC 6 ms
21,976 KB
testcase_15 AC 5 ms
21,708 KB
testcase_16 AC 5 ms
21,768 KB
testcase_17 AC 5 ms
21,732 KB
testcase_18 AC 5 ms
21,892 KB
testcase_19 AC 5 ms
21,768 KB
testcase_20 AC 5 ms
21,824 KB
testcase_21 AC 5 ms
21,728 KB
testcase_22 AC 6 ms
21,840 KB
testcase_23 AC 5 ms
21,772 KB
testcase_24 AC 5 ms
21,760 KB
testcase_25 AC 106 ms
21,780 KB
testcase_26 AC 7 ms
21,780 KB
testcase_27 AC 27 ms
21,708 KB
testcase_28 AC 53 ms
21,732 KB
testcase_29 AC 27 ms
21,716 KB
testcase_30 AC 246 ms
21,724 KB
testcase_31 AC 236 ms
21,784 KB
testcase_32 AC 9 ms
21,716 KB
testcase_33 AC 249 ms
21,844 KB
testcase_34 AC 246 ms
21,828 KB
testcase_35 AC 9 ms
21,732 KB
testcase_36 AC 7 ms
21,764 KB
testcase_37 AC 7 ms
21,816 KB
testcase_38 AC 11 ms
21,968 KB
testcase_39 AC 6 ms
21,768 KB
testcase_40 AC 111 ms
21,760 KB
testcase_41 AC 237 ms
21,820 KB
testcase_42 AC 247 ms
21,764 KB
testcase_43 AC 26 ms
21,872 KB
testcase_44 AC 243 ms
21,708 KB
testcase_45 AC 243 ms
22,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int INF = 1 << 30;

int N, A[18], B[18];
int dp[1 << 18][18];

int rec(int bit, int idx) {
  if(bit == (1 << N) - 1) return 0;
  if(~dp[bit][idx]) return dp[bit][idx];
  int ret = INF;
  for(int i = 0; i < N; i++) {
    if((bit >> i) & 1) continue;
    ret = min(ret, max(rec(bit | (1 << i), i), (B[idx] - A[idx]) + A[i]));
  }
  return dp[bit][idx] = ret;
}

int main() {
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  memset(dp, -1, sizeof(dp));
  int ret = INF;
  for(int i = 0; i < N; i++) ret = min(ret, rec(1 << i, i));
  cout << ret << endl;
}



0