結果
問題 | No.771 しおり |
ユーザー |
![]() |
提出日時 | 2018-12-18 23:07:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 365 ms / 2,000 ms |
コード長 | 1,322 bytes |
コンパイル時間 | 1,274 ms |
コンパイル使用メモリ | 125,428 KB |
最終ジャッジ日時 | 2025-01-06 19:38:18 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include<iostream>#include<vector>#include<algorithm>#include<set>#include<map>#include<unordered_map>#include<queue>#include<iomanip>#include<math.h>#include<bitset>#include<cassert>#include<random>#include<time.h>#include<functional>using namespace std;using ll=long long;using ld=long double;using P=pair<ll,ll>;#define MOD 998244353LL#define INF 1000000000LL#define EPS 1e-10#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)#define REP(i,n) FOR(i,0,n)#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}#define ALL(v) v.begin(),v.end()#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());#define pb push_backint main() {cin.tie(0);ios::sync_with_stdio(false);ll n;cin >> n;vector<ll> a(n);vector<ll> b(n);REP(i, n) cin >> a[i] >> b[i];vector<vector<ll>> dp((1ll << n), vector<ll>(n, INF));REP(bit, (1ll << n)) REP(i, n) {bitset<18> bi(bit);if(bi[i] == 0) continue;if(bi.count() == 1) {dp[bit][i] = 0;continue;}bi[i] = 0;REP(j, n) {if(bi[j] == 0 || j == i) continue;dp[bit][i] = min(dp[bit][i], max(dp[bi.to_ullong()][j], a[i] + (b[j] - a[j])));}}ll ans = INF;REP(i, n) ans = min(ans, dp[(1ll << n) - 1][i]);cout << ans << endl;return 0;}/* --------------------------------------- */