結果

問題 No.1045 直方体大学
ユーザー maspymaspy
提出日時 2020-05-01 21:47:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,240 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 110,096 KB
最終ジャッジ日時 2023-08-26 09:02:57
合計ジャッジ時間 14,343 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,296 KB
testcase_01 AC 71 ms
71,232 KB
testcase_02 WA -
testcase_03 AC 75 ms
75,580 KB
testcase_04 AC 79 ms
75,780 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 90 ms
76,312 KB
testcase_18 AC 1,144 ms
109,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**18
N = int(readline())
m = map(int, read().split())
ABC = list(zip(m, m, m))

pattern = [None] * (3 * N)
for i in range(N):
    a, b, c = sorted(ABC[i])
    pattern[3 * i] = (a, b, c)
    pattern[3 * i + 1] = (b, c, a)
    pattern[3 * i + 2] = (a, c, b)
dp = [[-INF] * (3 * N) for _ in range(1 << N)]

for i in range(N):
    for k in range(3):
        dp[1 << i][3 * i + k] = pattern[3 * i + k][2]

for s in range(1 << N):
    for i in range(N):
        if not (s & (1 << i)):
            continue
        for j in range(N):
            if s & (1 << j):
                continue
            t = s ^ (1 << j)
            for k in (3 * i, 3 * i + 1, 3 * i + 2):
                for l in (3 * j, 3 * j + 1, 3 * j + 2):
                    a1, b1, c1 = pattern[k]
                    a2, b2, c2 = pattern[l]
                    if a1 > a2:
                        continue
                    if b1 > b2:
                        continue
                    x = dp[s][k] + c2
                    if dp[t][k] < x:
                        dp[t][k] = x

answer = max(itertools.chain(*dp))
print(answer)
0