結果

問題 No.771 しおり
ユーザー Taiki0715Taiki0715
提出日時 2023-04-04 18:08:36
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 1,514 bytes
コンパイル時間 1,649 ms
コンパイル使用メモリ 142,720 KB
実行使用メモリ 29,856 KB
最終ジャッジ日時 2024-04-08 17:34:04
合計ジャッジ時間 7,495 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 305 ms
29,856 KB
testcase_01 AC 31 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 141 ms
16,512 KB
testcase_26 AC 5 ms
6,676 KB
testcase_27 AC 33 ms
6,676 KB
testcase_28 AC 73 ms
9,856 KB
testcase_29 AC 33 ms
6,676 KB
testcase_30 AC 306 ms
29,856 KB
testcase_31 AC 310 ms
29,856 KB
testcase_32 AC 8 ms
6,676 KB
testcase_33 AC 304 ms
29,856 KB
testcase_34 AC 297 ms
29,856 KB
testcase_35 AC 8 ms
6,676 KB
testcase_36 AC 4 ms
6,676 KB
testcase_37 AC 3 ms
6,676 KB
testcase_38 AC 8 ms
6,676 KB
testcase_39 AC 3 ms
6,676 KB
testcase_40 AC 132 ms
16,512 KB
testcase_41 AC 296 ms
29,856 KB
testcase_42 AC 284 ms
29,856 KB
testcase_43 AC 35 ms
6,676 KB
testcase_44 AC 285 ms
29,856 KB
testcase_45 AC 330 ms
29,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <cassert>
#include <bitset>
#include <map>
#include <algorithm>
#include <iterator>
#include <string>
#include <utility>
#include <numeric>
#include <regex>
#include <complex>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using P=pair<ll,ll>;
template<typename T>using minque=priority_queue<T,vector<T>,greater<T>>;
template<typename T>bool chmax(T &a,const T &b){return (a<b?(a=b,true):false);}
template<typename T>bool chmin(T &a,const T &b){return (a>b?(a=b,true):false);}
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
  os<<p.first<<" "<<p.second;
  return os;
}
template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
  is>>p.first>>p.second;
  return is;
}
template<typename T>
istream &operator>>(istream &is,vector<T> &a){
  for(auto &i:a)is>>i;
  return is;
}
#define reps(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) reps(i,0,n)
#define all(x) x.begin(),x.end()
ll myceil(ll a,ll b){return (a+b-1)/b;}
int main(){
  int n;
  cin>>n;
  vector<int>a(n),b(n);
  rep(i,n)cin>>a[i]>>b[i];
  vector<vector<int>>dp(1<<n,vector<int>(n,10000000));
  rep(i,n)dp[(1<<i)][i]=0;
  rep(i,1<<n){
    rep(j,n){
      rep(k,n){
        if(i&(1<<k))continue;
        chmin(dp[i|(1<<k)][k],max(dp[i][j],b[j]-a[j]+a[k]));
      }
    }
  }
  int ans=1e9;
  rep(i,n)chmin(ans,dp[(1<<n)-1][i]);
  cout<<ans<<endl;
}
0