結果

問題 No.771 しおり
ユーザー eQeeQe
提出日時 2020-02-22 07:36:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 925 bytes
コンパイル時間 1,379 ms
コンパイル使用メモリ 165,084 KB
実行使用メモリ 44,476 KB
最終ジャッジ日時 2023-09-29 13:01:28
合計ジャッジ時間 5,776 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 229 ms
44,232 KB
testcase_01 AC 25 ms
9,472 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 120 ms
25,776 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 27 ms
9,472 KB
testcase_28 AC 56 ms
15,628 KB
testcase_29 AC 26 ms
9,540 KB
testcase_30 AC 248 ms
44,416 KB
testcase_31 AC 251 ms
44,304 KB
testcase_32 AC 7 ms
4,632 KB
testcase_33 AC 260 ms
44,212 KB
testcase_34 AC 252 ms
44,348 KB
testcase_35 AC 7 ms
4,692 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 3 ms
4,380 KB
testcase_38 AC 7 ms
4,628 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 109 ms
25,772 KB
testcase_41 AC 247 ms
44,232 KB
testcase_42 AC 235 ms
44,424 KB
testcase_43 AC 27 ms
9,652 KB
testcase_44 AC 251 ms
44,476 KB
testcase_45 AC 216 ms
44,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


ll N;
ll a[20], b[20];

ll dp[1<<18][20];

int main(void) {
  cin >> N;
  ll i, j;
  
  for(i=0; i<N; i++) {
    cin >> a[i] >> b[i];
    b[i]-=a[i];
  }
  
  for(ll S=0; S<1<<N; S++) {
    for(ll u=0; u<N; u++) {
      dp[S][u]=INF;
    }
  }
  
  for(i=0; i<N; i++) dp[1<<i][i]=0;
  
  for(ll S=0; S<1<<N; S++) {
    for(ll u=0; u<N; u++) {
      if(!(S>>u&1)) continue;
      for(ll v=0; v<N; v++) {
        if(S>>v&1) continue;
        chmin(dp[S|1<<v][v], max(dp[S][u], b[u]+a[v]));
      }
    }
  }
  
  ll ans=INF;
  for(i=0; i<N; i++) {
    chmin(ans, dp[(1<<N)-1][i]);
  }
  pt(ans);
}





0