結果

問題 No.771 しおり
ユーザー iqueue02iqueue02
提出日時 2019-11-21 21:52:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 740 bytes
コンパイル時間 1,692 ms
コンパイル使用メモリ 168,944 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 09:26:23
合計ジャッジ時間 7,410 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 WA -
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 376 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];
  vector<int> dp(1<<n,INF);
  for (int i = 0; i < n; i++) dp[(1<<i)] = 0;
  int res = INF;
  for (int i = 0 ; i < n; i++) {
    auto dp2 = dp;
    for (int bit = 0; bit < (1 << n); bit++) {
      for (int j = 0; j < n; j++) {
        if (!(bit&(1<<j))) continue;
        if (bit&(1<<i)) continue;
        dp2[bit | (1 << i)] = min(dp2[bit | (1<<i)], max(dp[bit], b[i] - a[i] + a[j]));
      }
    }
    dp = dp2;
  }
  cout << dp[(1<<n)-1] << endl;
  return 0;
}
0