結果

問題 No.1045 直方体大学
ユーザー tpynerivertpyneriver
提出日時 2020-05-02 19:52:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 928 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 124,224 KB
最終ジャッジ日時 2023-08-30 02:59:47
合計ジャッジ時間 8,354 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,412 KB
testcase_01 AC 73 ms
71,136 KB
testcase_02 AC 79 ms
76,036 KB
testcase_03 WA -
testcase_04 AC 83 ms
75,620 KB
testcase_05 AC 123 ms
76,196 KB
testcase_06 AC 98 ms
76,276 KB
testcase_07 AC 101 ms
76,356 KB
testcase_08 AC 544 ms
123,628 KB
testcase_09 AC 537 ms
123,676 KB
testcase_10 AC 563 ms
123,496 KB
testcase_11 AC 547 ms
123,572 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 96 ms
76,500 KB
testcase_18 AC 784 ms
122,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter
readline = sys.stdin.readline

def compress(L):
    L2 = list(set(L))
    L2.sort()
    C = {v : k for k, v in enumerate(L2)}
    return L2, C


N = int(readline())
Box = []
LL = []
for i in range(N):
    a, b, c = map(int, readline().split())
    a, b, c = sorted([a, b, c])
    LL.extend([c, c, b])
    Box.append((i, 0, a, b, c))
    Box.append((i, 1, b, a, c))
    Box.append((i, 2, c, a, b))

Box.sort(key = itemgetter(3))
dp = [[0]*(3*N) for _ in range(1<<N)]
for i, ori, point, _, w in Box:
    dp2 = dp[:]
    look = []
    widx = 3*i+ori
    for j in range(3*N):
        if j != widx and LL[j] <= w:
            look.append(j)
    for S in range(1<<N):
        if not (1<<i) & S:
            continue
        T = S^(1<<i)
        res = 0
        for j in look:
            res = max(res, dp[T][j])
        dp[S][widx] = res + point
    
print(max(max(d) for d in dp))
        
0