結果

問題 No.1045 直方体大学
ユーザー mkawa2mkawa2
提出日時 2021-05-13 12:25:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,836 ms / 2,000 ms
コード長 1,467 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 106,584 KB
最終ジャッジ日時 2023-10-25 06:28:29
合計ジャッジ時間 4,831 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,568 KB
testcase_01 AC 39 ms
53,568 KB
testcase_02 AC 40 ms
53,568 KB
testcase_03 AC 39 ms
53,568 KB
testcase_04 AC 39 ms
53,568 KB
testcase_05 AC 58 ms
66,500 KB
testcase_06 AC 59 ms
66,496 KB
testcase_07 AC 56 ms
64,508 KB
testcase_08 AC 136 ms
103,868 KB
testcase_09 AC 131 ms
103,808 KB
testcase_10 AC 126 ms
103,796 KB
testcase_11 AC 129 ms
103,796 KB
testcase_12 AC 138 ms
103,796 KB
testcase_13 AC 159 ms
103,792 KB
testcase_14 AC 138 ms
103,816 KB
testcase_15 AC 152 ms
103,804 KB
testcase_16 AC 162 ms
103,804 KB
testcase_17 AC 59 ms
64,424 KB
testcase_18 AC 1,836 ms
106,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
dij = [(0, 1), (1, 0), (1, 1), (1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

n = II()
ihwt = []
for i in range(n):
    a, b, c = sorted(LI())
    ihwt.append((i, a, b, c))
    ihwt.append((i, a, c, b))
    ihwt.append((i, b, c, a))
ihwt.sort(key=lambda x: (x[1], x[2]))

def chmax(s, j, val):
    if val > dp[s][j]: dp[s][j] = val

ans = 0
dp = [[-1]*n*3 for _ in range(1 << n)]
for j, (i, h, w, t) in enumerate(ihwt): dp[1 << i][j] = t
for s in range(1 << n):
    for j in range(n*3):
        pre = dp[s][j]
        if pre == -1: continue
        if pre > ans: ans = pre
        _, H, W, T = ihwt[j]
        for nj, (i, h, w, t) in enumerate(ihwt):
            if h > H: break
            if w > W: continue
            if s >> i & 1: continue
            chmax(s | 1 << i, nj, pre+t)

print(ans)
0