結果

問題 No.1045 直方体大学
ユーザー QCFiumQCFium
提出日時 2020-05-01 22:12:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 511 ms / 2,000 ms
コード長 916 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 165,684 KB
実行使用メモリ 28,344 KB
最終ジャッジ日時 2023-08-26 14:18:56
合計ジャッジ時間 7,356 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 508 ms
28,124 KB
testcase_09 AC 507 ms
28,344 KB
testcase_10 AC 485 ms
28,012 KB
testcase_11 AC 494 ms
28,280 KB
testcase_12 AC 497 ms
28,088 KB
testcase_13 AC 484 ms
28,096 KB
testcase_14 AC 482 ms
28,024 KB
testcase_15 AC 502 ms
28,016 KB
testcase_16 AC 511 ms
28,012 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 401 ms
28,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri();
	int a[n], b[n], c[n];
	for (int i = 0; i < n; i++) a[i] = ri(), b[i] = ri(), c[i] = ri();
	
	int *list[6][3] = {
		{a, b, c},
		{a, c, b},
		{b, a, c},
		{b, c, a},
		{c, a, b},
		{c, b, a}
	};
	int dp[1 << n][n][6];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < n; i++) for (int j = 0; j < 6; j++) dp[1 << i][i][j] = list[j][2][i];
	for (int i = 0; i < 1 << n; i++) for (int j = 0; j < n; j++) if (i >> j & 1)
		for (int k = 0; k < 6; k++) for (int l = 0; l < n; l++) if (!(i >> l & 1))
			for (int m = 0; m < 6; m++) if (list[m][0][l] <= list[k][0][j] && list[m][1][l] <= list[k][1][j])
				dp[i | 1 << l][l][m] = std::max(dp[i | 1 << l][l][m], dp[i][j][k] + list[m][2][l]);
	int res = 0;
	for (auto &i : dp) for (auto &j : i) for (auto &k : j) res = std::max(res, k);
	printf("%d\n", res);
	return 0;
}


0