結果

問題 No.771 しおり
ユーザー 夜
提出日時 2021-02-04 06:15:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 1,246 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 92,296 KB
実行使用メモリ 26,104 KB
最終ジャッジ日時 2023-09-29 13:04:51
合計ジャッジ時間 5,046 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 210 ms
25,868 KB
testcase_01 AC 24 ms
7,348 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 111 ms
15,840 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 25 ms
7,620 KB
testcase_28 AC 53 ms
9,484 KB
testcase_29 AC 25 ms
7,336 KB
testcase_30 AC 228 ms
25,884 KB
testcase_31 AC 235 ms
25,784 KB
testcase_32 AC 7 ms
4,380 KB
testcase_33 AC 240 ms
25,856 KB
testcase_34 AC 233 ms
25,872 KB
testcase_35 AC 7 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 7 ms
4,380 KB
testcase_39 AC 3 ms
4,376 KB
testcase_40 AC 101 ms
15,732 KB
testcase_41 AC 231 ms
25,856 KB
testcase_42 AC 218 ms
25,852 KB
testcase_43 AC 25 ms
7,404 KB
testcase_44 AC 228 ms
26,104 KB
testcase_45 AC 196 ms
25,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int dp[300030][20];
int d[20][20];
int a[20], b[20];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < n; j++) {
			dp[i][j] = 1000000007;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		b[i] -= a[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				d[i][j] = 0;
			}
			else {
				d[i][j] = b[i] + a[j];
			}
		}
	}
	for (int i = 0; i < n; i++) {
		dp[(1 << i)][i] = 0;
	}
	for (int i = 0; i < (1 << n); i++) {
		for (int v = 0; v < n; v++) {
			if (!(i & (1 << v))) {
				continue;
			}
			for (int u = 0; u < n; u++) {
				if (i & (1 << u)) {
					continue;
				}
				dp[i | (1 << u)][u] = min(dp[i | (1 << u)][u], max(dp[i][v], d[v][u]));
			}
		}
	}
	int ans = 1000000007;
	for (int i = 0; i < n; i++) {
		if (ans > dp[(1 << n) - 1][i]) {
			ans = dp[(1 << n) - 1][i];
		}
	}
	cout << ans << endl;
}
0