結果

問題 No.771 しおり
ユーザー chocoruskchocorusk
提出日時 2018-12-18 23:20:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 959 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 92,756 KB
実行使用メモリ 21,868 KB
最終ジャッジ日時 2023-09-29 12:46:04
合計ジャッジ時間 3,864 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 166 ms
21,840 KB
testcase_01 AC 18 ms
17,908 KB
testcase_02 AC 1 ms
5,452 KB
testcase_03 AC 2 ms
5,500 KB
testcase_04 AC 1 ms
5,404 KB
testcase_05 AC 2 ms
7,576 KB
testcase_06 AC 1 ms
5,384 KB
testcase_07 AC 2 ms
7,508 KB
testcase_08 AC 2 ms
11,548 KB
testcase_09 AC 2 ms
4,504 KB
testcase_10 AC 2 ms
5,400 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
5,500 KB
testcase_13 AC 2 ms
7,400 KB
testcase_14 AC 3 ms
11,612 KB
testcase_15 AC 1 ms
5,404 KB
testcase_16 AC 2 ms
9,500 KB
testcase_17 AC 2 ms
9,432 KB
testcase_18 AC 2 ms
5,596 KB
testcase_19 AC 1 ms
7,384 KB
testcase_20 AC 2 ms
5,356 KB
testcase_21 AC 2 ms
5,360 KB
testcase_22 AC 2 ms
7,384 KB
testcase_23 AC 2 ms
9,484 KB
testcase_24 AC 2 ms
11,560 KB
testcase_25 AC 74 ms
20,572 KB
testcase_26 AC 4 ms
13,792 KB
testcase_27 AC 17 ms
17,952 KB
testcase_28 AC 35 ms
18,304 KB
testcase_29 AC 17 ms
17,896 KB
testcase_30 AC 161 ms
21,784 KB
testcase_31 AC 157 ms
21,784 KB
testcase_32 AC 5 ms
15,660 KB
testcase_33 AC 159 ms
21,868 KB
testcase_34 AC 160 ms
21,832 KB
testcase_35 AC 6 ms
15,600 KB
testcase_36 AC 2 ms
13,592 KB
testcase_37 AC 3 ms
13,616 KB
testcase_38 AC 5 ms
15,676 KB
testcase_39 AC 3 ms
13,552 KB
testcase_40 AC 75 ms
20,480 KB
testcase_41 AC 162 ms
21,732 KB
testcase_42 AC 162 ms
21,704 KB
testcase_43 AC 17 ms
17,900 KB
testcase_44 AC 157 ms
21,708 KB
testcase_45 AC 157 ms
21,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	int a[18], b[18];
	for(int i=0; i<n; i++) cin>>a[i]>>b[i];
	int dp[18][1<<18];
	for(int i=0; i<n; i++){
		for(int j=0; j<(1<<n); j++){
			if(j==(1<<i)) dp[i][j]=0;
			else dp[i][j]=10000;
		}
	}
	for(int i=1; i<(1<<n); i++){
		for(int j=0; j<n; j++){
			if((i&(1<<j))==0) continue;
			for(int k=0; k<n; k++){
				if(((i-(1<<j))&(1<<k))==0) continue;
				dp[j][i]=min(dp[j][i], max(dp[k][i-(1<<j)], b[k]-a[k]+a[j]));
			}
		}
	}
	int ans=10000;
	for(int i=0; i<n; i++){
		ans=min(ans, dp[i][(1<<n)-1]);
	}
	cout<<ans<<endl;
	return 0;
}
0