結果

問題 No.1045 直方体大学
ユーザー tpyneriver
提出日時 2020-05-02 19:55:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 975 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,856 KB
実行使用メモリ 121,768 KB
最終ジャッジ日時 2024-12-31 09:27:34
合計ジャッジ時間 7,583 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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))
LL.append(0)
Box.sort(key = itemgetter(3))
INF = 10**9+7
dp = [[-INF]*(3*N+1) for _ in range(1<<N)]
dp[0][-1] = 0
for i, ori, point, _, w in Box:
    dp2 = dp[:]
    look = []
    widx = 3*i+ori
    for j in range(3*N+1):
        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