結果

問題 No.771 しおり
ユーザー 0w10w1
提出日時 2018-12-31 02:47:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 203,856 KB
実行使用メモリ 29,796 KB
最終ジャッジ日時 2023-09-29 12:50:15
合計ジャッジ時間 6,606 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 253 ms
29,552 KB
testcase_01 AC 26 ms
6,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 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,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 119 ms
16,276 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 27 ms
6,440 KB
testcase_28 AC 56 ms
9,708 KB
testcase_29 AC 26 ms
6,480 KB
testcase_30 AC 255 ms
29,540 KB
testcase_31 AC 254 ms
29,472 KB
testcase_32 AC 7 ms
4,380 KB
testcase_33 AC 255 ms
29,496 KB
testcase_34 AC 256 ms
29,544 KB
testcase_35 AC 6 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 3 ms
4,380 KB
testcase_38 AC 7 ms
4,380 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 119 ms
16,212 KB
testcase_41 AC 254 ms
29,496 KB
testcase_42 AC 255 ms
29,796 KB
testcase_43 AC 26 ms
6,400 KB
testcase_44 AC 256 ms
29,540 KB
testcase_45 AC 255 ms
29,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i];
  }

  vector<vector<int>> dp(1 << N, vector<int>(N, 0x3f3f3f3f));
  for (int i = 0; i < N; ++i) dp[1 << i][i] = 0;
  for (int s = 1; s + 1 < 1 << N; ++s) {
    for (int i = 0; i < N; ++i) {
      if (~s >> i & 1) continue;
      for (int j = 0; j < N; ++j) {
        if (i == j) continue;
        if (s >> j & 1) continue;
        dp[s | 1 << j][j] = min(dp[s | 1 << j][j], max(dp[s][i], B[i] - A[i] + A[j]));
      }
    }
  }

  cout << *min_element(dp.back().begin(), dp.back().end()) << endl;

  return 0;
}
0