結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,208 KB
testcase_01 AC 77 ms
71,216 KB
testcase_02 AC 81 ms
75,648 KB
testcase_03 WA -
testcase_04 AC 81 ms
75,952 KB
testcase_05 AC 103 ms
76,440 KB
testcase_06 AC 99 ms
76,296 KB
testcase_07 AC 99 ms
76,292 KB
testcase_08 AC 564 ms
123,696 KB
testcase_09 AC 548 ms
123,564 KB
testcase_10 AC 578 ms
123,500 KB
testcase_11 AC 791 ms
123,704 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 94 ms
76,496 KB
testcase_18 AC 792 ms
122,360 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))
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