結果

問題 No.771 しおり
ユーザー eQeeQe
提出日時 2020-02-22 07:33:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 408 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 1,576 ms
コンパイル使用メモリ 167,672 KB
実行使用メモリ 44,492 KB
最終ジャッジ日時 2024-07-22 07:20:19
合計ジャッジ時間 7,127 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 342 ms
44,456 KB
testcase_01 AC 41 ms
9,008 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 182 ms
24,940 KB
testcase_26 AC 6 ms
6,940 KB
testcase_27 AC 41 ms
8,664 KB
testcase_28 AC 92 ms
15,784 KB
testcase_29 AC 42 ms
9,372 KB
testcase_30 AC 387 ms
44,464 KB
testcase_31 AC 397 ms
44,428 KB
testcase_32 AC 10 ms
6,940 KB
testcase_33 AC 408 ms
44,488 KB
testcase_34 AC 390 ms
44,284 KB
testcase_35 AC 10 ms
6,940 KB
testcase_36 AC 4 ms
6,940 KB
testcase_37 AC 4 ms
6,940 KB
testcase_38 AC 10 ms
6,944 KB
testcase_39 AC 3 ms
6,940 KB
testcase_40 AC 164 ms
24,204 KB
testcase_41 AC 399 ms
44,400 KB
testcase_42 AC 369 ms
44,436 KB
testcase_43 AC 40 ms
9,408 KB
testcase_44 AC 387 ms
44,492 KB
testcase_45 AC 333 ms
44,312 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++) {
      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