結果

問題 No.1045 直方体大学
ユーザー roarisroaris
提出日時 2020-05-07 23:37:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,057 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 79,028 KB
最終ジャッジ日時 2023-09-16 08:11:48
合計ジャッジ時間 5,741 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,500 KB
testcase_01 AC 70 ms
71,256 KB
testcase_02 AC 85 ms
76,356 KB
testcase_03 AC 84 ms
75,836 KB
testcase_04 AC 83 ms
75,808 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
ABC = [tuple(map(int, input().split())) for _ in range(N)]
L = [[] for _ in range(N)]

for i in range(N):
    L[i].append((0, ABC[i][0], ABC[i][1], ABC[i][2]))
    L[i].append((1, ABC[i][0], ABC[i][2], ABC[i][1]))
    L[i].append((2, ABC[i][1], ABC[i][0], ABC[i][2]))
    L[i].append((3, ABC[i][1], ABC[i][2], ABC[i][0]))
    L[i].append((4, ABC[i][2], ABC[i][0], ABC[i][1]))
    L[i].append((5, ABC[i][2], ABC[i][1], ABC[i][0]))

dp = [[[0]*6 for _ in range(N)] for _ in range(1<<N)]

for i in range(N):
    for j, _, _, l3 in L[i]:
        dp[1<<i][i][j] = l3

for S in range(1, 1<<N):
    for i in range(N):
        if (S>>i)&1:
            for j in range(N):
                if not (S>>j)&1:
                    for k, pl1, pl2, _ in L[i]:
                        for l, l1, l2, l3 in L[j]:
                            if l1<=pl1 and l2<=pl2:
                                dp[S|(1<<j)][j][l] = max(dp[S|(1<<j)][j][l], dp[S][i][k]+l3)

ans = 0

for i in range(N):
    for j in range(6):
        ans = max(ans, dp[-1][i][j])

print(ans)
0