結果

問題 No.771 しおり
ユーザー gazellegazelle
提出日時 2018-12-18 23:07:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 1,322 bytes
コンパイル時間 1,226 ms
コンパイル使用メモリ 127,608 KB
実行使用メモリ 50,260 KB
最終ジャッジ日時 2023-09-29 12:44:38
合計ジャッジ時間 5,427 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 259 ms
50,100 KB
testcase_01 AC 25 ms
8,292 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 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 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 118 ms
24,556 KB
testcase_26 AC 4 ms
4,376 KB
testcase_27 AC 27 ms
8,288 KB
testcase_28 AC 57 ms
13,780 KB
testcase_29 AC 25 ms
7,772 KB
testcase_30 AC 258 ms
50,212 KB
testcase_31 AC 257 ms
50,204 KB
testcase_32 AC 6 ms
4,384 KB
testcase_33 AC 258 ms
50,260 KB
testcase_34 AC 260 ms
50,200 KB
testcase_35 AC 7 ms
4,380 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 3 ms
4,380 KB
testcase_38 AC 7 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 120 ms
24,600 KB
testcase_41 AC 267 ms
50,200 KB
testcase_42 AC 277 ms
50,088 KB
testcase_43 AC 25 ms
7,804 KB
testcase_44 AC 264 ms
50,092 KB
testcase_45 AC 262 ms
50,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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_back

int 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;
}

/* --------------------------------------- */
0