結果

問題 No.771 しおり
ユーザー kriiikriii
提出日時 2018-12-18 23:10:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,403 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 32,384 KB
実行使用メモリ 7,660 KB
最終ジャッジ日時 2023-09-29 12:45:20
合計ジャッジ時間 12,127 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 441 ms
7,592 KB
testcase_01 AC 90 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 477 ms
7,008 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 93 ms
4,376 KB
testcase_28 AC 194 ms
4,376 KB
testcase_29 AC 115 ms
4,376 KB
testcase_30 AC 1,359 ms
7,508 KB
testcase_31 AC 1,403 ms
7,580 KB
testcase_32 AC 20 ms
4,376 KB
testcase_33 AC 1,060 ms
7,584 KB
testcase_34 AC 1,065 ms
7,540 KB
testcase_35 AC 26 ms
4,376 KB
testcase_36 AC 4 ms
4,376 KB
testcase_37 AC 4 ms
4,376 KB
testcase_38 AC 21 ms
4,376 KB
testcase_39 AC 6 ms
4,380 KB
testcase_40 AC 382 ms
7,064 KB
testcase_41 AC 621 ms
7,608 KB
testcase_42 AC 1,198 ms
7,596 KB
testcase_43 AC 83 ms
4,380 KB
testcase_44 AC 1,244 ms
7,660 KB
testcase_45 AC 201 ms
7,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int N,A[18],B[18]; bool C[1<<18][18];

bool chk(int x)
{
	for (int j=1;j<(1<<N);j++) for (int i=0;i<N;i++) C[j][i] = 0;
	for (int i=0;i<N;i++) C[1<<i][i] = 1;
	for (int j=1;j<(1<<N);j++){
		for (int i=0;i<N;i++) if (C[j][i]){
			for (int k=0;k<N;k++) if (~j & (1 << k)){
				if (B[i] - A[i] + A[k] <= x) C[j+(1<<k)][k] = 1;
			}
		}
	}

	bool g = 0;
	for (int i=0;i<N;i++) if (C[(1<<N)-1][i]) g = 1;
	return g;
}

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<N;i++) scanf ("%d %d",&A[i],&B[i]);

	int l = 0, r = 2222;
	while (l + 1 < r){
		int m = (l + r) / 2;
		if (chk(m)) r = m;
		else l = m;
	}
	printf ("%d\n",r);
	return 0;
}
0