結果

問題 No.771 しおり
ユーザー eQeeQe
提出日時 2020-02-22 07:40:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 930 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 144,900 KB
実行使用メモリ 44,460 KB
最終ジャッジ日時 2023-09-29 13:01:55
合計ジャッジ時間 5,401 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 213 ms
44,280 KB
testcase_01 AC 25 ms
8,756 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 2 ms
4,504 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,376 KB
testcase_25 AC 112 ms
24,156 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 26 ms
8,728 KB
testcase_28 AC 54 ms
13,800 KB
testcase_29 AC 26 ms
9,308 KB
testcase_30 AC 228 ms
44,460 KB
testcase_31 AC 237 ms
44,256 KB
testcase_32 AC 7 ms
5,596 KB
testcase_33 AC 250 ms
44,400 KB
testcase_34 AC 238 ms
44,260 KB
testcase_35 AC 7 ms
4,652 KB
testcase_36 AC 3 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 7 ms
5,556 KB
testcase_39 AC 3 ms
4,376 KB
testcase_40 AC 99 ms
24,316 KB
testcase_41 AC 236 ms
44,224 KB
testcase_42 AC 218 ms
44,460 KB
testcase_43 AC 27 ms
9,336 KB
testcase_44 AC 235 ms
44,276 KB
testcase_45 AC 192 ms
44,260 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;


int main(void) {
  ll N;
  cin >> N;
  
  ll a[20], b[20];
  ll dp[1<<18][20];
  
  for(ll 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(ll u=0; u<N; u++) dp[1<<u][u]=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(ll i=0; i<N; i++) {
    chmin(ans, dp[(1<<N)-1][i]);
  }
  pt(ans);
}





0