結果

問題 No.771 しおり
ユーザー eQeeQe
提出日時 2020-02-22 06:32:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 374 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 1,086 ms
コンパイル使用メモリ 144,176 KB
実行使用メモリ 48,648 KB
最終ジャッジ日時 2023-09-29 13:01:09
合計ジャッジ時間 7,374 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 356 ms
48,384 KB
testcase_01 AC 41 ms
48,408 KB
testcase_02 AC 13 ms
48,456 KB
testcase_03 AC 13 ms
48,508 KB
testcase_04 AC 13 ms
48,572 KB
testcase_05 AC 13 ms
48,648 KB
testcase_06 AC 13 ms
48,380 KB
testcase_07 AC 13 ms
48,404 KB
testcase_08 AC 13 ms
48,448 KB
testcase_09 AC 13 ms
48,472 KB
testcase_10 AC 13 ms
48,468 KB
testcase_11 AC 13 ms
48,312 KB
testcase_12 AC 13 ms
48,460 KB
testcase_13 AC 13 ms
48,332 KB
testcase_14 AC 14 ms
48,564 KB
testcase_15 AC 13 ms
48,408 KB
testcase_16 AC 13 ms
48,308 KB
testcase_17 AC 13 ms
48,448 KB
testcase_18 AC 13 ms
48,372 KB
testcase_19 AC 13 ms
48,468 KB
testcase_20 AC 13 ms
48,644 KB
testcase_21 AC 13 ms
48,328 KB
testcase_22 AC 13 ms
48,512 KB
testcase_23 AC 13 ms
48,404 KB
testcase_24 AC 13 ms
48,456 KB
testcase_25 AC 168 ms
48,388 KB
testcase_26 AC 16 ms
48,408 KB
testcase_27 AC 42 ms
48,456 KB
testcase_28 AC 77 ms
48,400 KB
testcase_29 AC 40 ms
48,324 KB
testcase_30 AC 352 ms
48,324 KB
testcase_31 AC 366 ms
48,404 KB
testcase_32 AC 18 ms
48,320 KB
testcase_33 AC 374 ms
48,516 KB
testcase_34 AC 354 ms
48,404 KB
testcase_35 AC 18 ms
48,404 KB
testcase_36 AC 14 ms
48,464 KB
testcase_37 AC 14 ms
48,324 KB
testcase_38 AC 19 ms
48,408 KB
testcase_39 AC 15 ms
48,328 KB
testcase_40 AC 163 ms
48,400 KB
testcase_41 AC 359 ms
48,372 KB
testcase_42 AC 363 ms
48,308 KB
testcase_43 AC 42 ms
48,388 KB
testcase_44 AC 355 ms
48,324 KB
testcase_45 AC 373 ms
48,404 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 mem[1<<18][22];
ll N;
ll a[22], b[22];

ll rec(ll S, ll v) {
  if(mem[S][v]!=-1) return mem[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(S==0) {
      chmin(res, rec(S|1<<u, u));
    }else {
      chmin(res, max(rec(S|1<<u, u), b[v]+a[u]));
    }
  }
  
  return mem[S][v]=res;
  
}

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





0