結果

問題 No.771 しおり
ユーザー eQeeQe
提出日時 2020-02-22 07:30:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 1,148 ms
コンパイル使用メモリ 145,052 KB
実行使用メモリ 44,496 KB
最終ジャッジ日時 2023-09-29 13:00:30
合計ジャッジ時間 6,323 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 272 ms
44,200 KB
testcase_01 AC 32 ms
9,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 148 ms
25,788 KB
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 34 ms
9,404 KB
testcase_28 AC 74 ms
15,556 KB
testcase_29 AC 34 ms
9,524 KB
testcase_30 AC 309 ms
44,316 KB
testcase_31 AC 322 ms
44,212 KB
testcase_32 AC 8 ms
4,532 KB
testcase_33 AC 323 ms
44,496 KB
testcase_34 AC 308 ms
44,228 KB
testcase_35 AC 9 ms
4,672 KB
testcase_36 AC 3 ms
4,380 KB
testcase_37 AC 3 ms
4,380 KB
testcase_38 AC 8 ms
4,560 KB
testcase_39 AC 3 ms
4,376 KB
testcase_40 AC 132 ms
25,912 KB
testcase_41 AC 309 ms
44,344 KB
testcase_42 AC 292 ms
44,200 KB
testcase_43 AC 34 ms
9,556 KB
testcase_44 AC 305 ms
44,308 KB
testcase_45 AC 254 ms
44,288 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