結果

問題 No.771 しおり
ユーザー chocoruskchocorusk
提出日時 2018-12-18 23:12:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,076 ms / 2,000 ms
コード長 1,065 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 91,792 KB
実行使用メモリ 8,184 KB
最終ジャッジ日時 2023-09-29 12:45:44
合計ジャッジ時間 13,460 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 900 ms
7,928 KB
testcase_01 AC 78 ms
7,932 KB
testcase_02 AC 6 ms
7,908 KB
testcase_03 AC 5 ms
7,956 KB
testcase_04 AC 5 ms
7,884 KB
testcase_05 AC 5 ms
7,992 KB
testcase_06 AC 5 ms
7,960 KB
testcase_07 AC 6 ms
7,932 KB
testcase_08 AC 6 ms
7,880 KB
testcase_09 AC 6 ms
7,900 KB
testcase_10 AC 5 ms
7,960 KB
testcase_11 AC 6 ms
8,148 KB
testcase_12 AC 5 ms
8,036 KB
testcase_13 AC 6 ms
8,184 KB
testcase_14 AC 8 ms
7,892 KB
testcase_15 AC 5 ms
7,900 KB
testcase_16 AC 5 ms
7,880 KB
testcase_17 AC 6 ms
8,152 KB
testcase_18 AC 5 ms
7,908 KB
testcase_19 AC 4 ms
7,876 KB
testcase_20 AC 6 ms
7,932 KB
testcase_21 AC 5 ms
7,992 KB
testcase_22 AC 6 ms
7,900 KB
testcase_23 AC 5 ms
7,904 KB
testcase_24 AC 6 ms
7,960 KB
testcase_25 AC 500 ms
7,980 KB
testcase_26 AC 14 ms
7,976 KB
testcase_27 AC 99 ms
7,928 KB
testcase_28 AC 252 ms
7,960 KB
testcase_29 AC 95 ms
8,028 KB
testcase_30 AC 1,049 ms
7,920 KB
testcase_31 AC 1,049 ms
7,980 KB
testcase_32 AC 24 ms
7,884 KB
testcase_33 AC 1,076 ms
7,960 KB
testcase_34 AC 902 ms
7,908 KB
testcase_35 AC 27 ms
7,980 KB
testcase_36 AC 9 ms
7,900 KB
testcase_37 AC 10 ms
7,932 KB
testcase_38 AC 27 ms
8,184 KB
testcase_39 AC 10 ms
7,900 KB
testcase_40 AC 355 ms
7,892 KB
testcase_41 AC 1,009 ms
8,036 KB
testcase_42 AC 850 ms
7,896 KB
testcase_43 AC 97 ms
7,988 KB
testcase_44 AC 962 ms
8,092 KB
testcase_45 AC 851 ms
7,876 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];
	
	int d1=0, d2=2000;
	while(d1!=d2){
		int d=(d1+d2)/2;
		bool dp[18][1<<18]={};
		for(int i=0; i<n; i++){
			dp[i][1<<i]=1;
		}
		for(int i=0; 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(!dp[k][i-(1<<j)]) continue;
					if(((i-(1<<j))&(1<<k))==0) continue;
					if(b[k]-a[k]+a[j]<=d){
						dp[j][i]=1;
						break;
					}
				}
			}
		}
		bool ok=0;
		for(int i=0; i<n; i++){
			if(dp[i][(1<<n)-1]){
				ok=1;
				break;
			}
		}
		if(ok) d2=d;
		else d1=d+1;
	}
	cout<<d1<<endl;
	return 0;
}
0