結果

問題 No.771 しおり
ユーザー eQeeQe
提出日時 2019-04-17 21:28:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 341 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 1,288 ms
コンパイル使用メモリ 144,104 KB
実行使用メモリ 44,476 KB
最終ジャッジ日時 2023-09-29 12:53:50
合計ジャッジ時間 6,388 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 303 ms
44,212 KB
testcase_01 AC 36 ms
44,424 KB
testcase_02 AC 11 ms
44,284 KB
testcase_03 AC 11 ms
44,276 KB
testcase_04 AC 10 ms
44,348 KB
testcase_05 AC 10 ms
44,272 KB
testcase_06 AC 11 ms
44,312 KB
testcase_07 AC 12 ms
44,284 KB
testcase_08 AC 11 ms
44,300 KB
testcase_09 AC 11 ms
44,208 KB
testcase_10 AC 11 ms
44,424 KB
testcase_11 AC 11 ms
44,220 KB
testcase_12 AC 10 ms
44,224 KB
testcase_13 AC 11 ms
44,200 KB
testcase_14 AC 11 ms
44,284 KB
testcase_15 AC 10 ms
44,348 KB
testcase_16 AC 11 ms
44,268 KB
testcase_17 AC 11 ms
44,304 KB
testcase_18 AC 11 ms
44,248 KB
testcase_19 AC 10 ms
44,284 KB
testcase_20 AC 11 ms
44,476 KB
testcase_21 AC 11 ms
44,352 KB
testcase_22 AC 10 ms
44,420 KB
testcase_23 AC 11 ms
44,212 KB
testcase_24 AC 12 ms
44,308 KB
testcase_25 AC 146 ms
44,200 KB
testcase_26 AC 13 ms
44,280 KB
testcase_27 AC 39 ms
44,224 KB
testcase_28 AC 73 ms
44,244 KB
testcase_29 AC 37 ms
44,216 KB
testcase_30 AC 312 ms
44,432 KB
testcase_31 AC 341 ms
44,348 KB
testcase_32 AC 16 ms
44,304 KB
testcase_33 AC 328 ms
44,200 KB
testcase_34 AC 321 ms
44,224 KB
testcase_35 AC 16 ms
44,296 KB
testcase_36 AC 11 ms
44,464 KB
testcase_37 AC 12 ms
44,232 KB
testcase_38 AC 16 ms
44,280 KB
testcase_39 AC 11 ms
44,200 KB
testcase_40 AC 150 ms
44,248 KB
testcase_41 AC 338 ms
44,232 KB
testcase_42 AC 333 ms
44,196 KB
testcase_43 AC 37 ms
44,208 KB
testcase_44 AC 321 ms
44,308 KB
testcase_45 AC 339 ms
44,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#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=1e5+7;
static const ll MOD=1e9+7;



ll N;
ll a[20], b[20];
ll dp[1<<18][20];

ll rec(ll S, ll v) {
  if(dp[S][v]>=0) return dp[S][v];
  
  if(S==(1<<N)-1) return 0;
  
  ll res=INF;
  for(ll u=0; u<N; u++) {
    if(S>>u&1) continue;
    
    if(v==N) {
      chmin(res, rec(S|1<<u, u));
    }else {
      chmin(res, max(rec(S|1<<u, u), b[v]+a[u]));
    }
  }
  
  return dp[S][v]=res;
}

int main(void) {
  ll i;
  cin >> N;
  
  for(i=0; i<N; i++) {
    cin >> a[i] >> b[i];
    b[i]-=a[i];
  }
  
  memset(dp, -1, sizeof(dp));
  pt(rec(0, N));
}




0