結果

問題 No.1045 直方体大学
ユーザー mkawa2mkawa2
提出日時 2021-05-12 07:51:32
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,430 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 106,500 KB
最終ジャッジ日時 2023-10-23 20:00:07
合計ジャッジ時間 19,225 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,392 KB
testcase_01 AC 35 ms
53,392 KB
testcase_02 AC 48 ms
61,836 KB
testcase_03 AC 48 ms
62,056 KB
testcase_04 AC 48 ms
62,160 KB
testcase_05 AC 68 ms
66,368 KB
testcase_06 AC 67 ms
66,360 KB
testcase_07 AC 65 ms
66,284 KB
testcase_08 AC 1,585 ms
106,416 KB
testcase_09 AC 1,581 ms
106,420 KB
testcase_10 AC 1,656 ms
106,436 KB
testcase_11 AC 1,639 ms
106,340 KB
testcase_12 AC 1,715 ms
106,432 KB
testcase_13 AC 1,657 ms
106,436 KB
testcase_14 AC 1,600 ms
106,352 KB
testcase_15 AC 1,569 ms
106,412 KB
testcase_16 AC 1,767 ms
106,436 KB
testcase_17 AC 56 ms
64,296 KB
testcase_18 TLE -
権限があれば一括ダウンロードができます

ソースコード

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 = [[0]*n*3 for _ in range(1 << n)]
for j, (i, h, w, t) in enumerate(ihwt): chmax(1 << i, j, t)
for s in range(1 << n):
    for j in range(n*3):
        pre = dp[s][j]
        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