結果

問題 No.1045 直方体大学
ユーザー convexineq
提出日時 2020-05-01 22:54:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 902 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-12-25 13:56:51
合計ジャッジ時間 6,603 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 3 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,m,s = [int(i) for i in readline().split()]
n = int(input())
abc = [tuple(sorted(int(i) for i in readline().split())) for _ in range(n)]

from bisect import *
def solve(lst,n):
    lst.sort()
    dp = [0]*(n+1) 
    for i,(w,h,c) in enumerate(lst):
        for j in range(i):
            if h >= lst[j][1]:
                dp[i] = max(dp[i], dp[j]+c)
    #print(lst,dp)
    return max(dp)
#print(dp)
 

N = 2**n
ans = 0
for mask in range(N):
    res = [(0,0,0)]
    for i,(a,b,c) in enumerate(abc):
        if mask>>i&1: res.append((a,c,b))
        else: res.append((a,b,c))
        """
        v = mask%3
        mask //= 3
        if v==0: res.append((a,c,b))
        elif v==1: res.append((a,b,c))
        else: res.append((b,c,a))
        """    
    ans = max(ans,solve(res,n))    

print(ans)



0