結果
問題 | No.1045 直方体大学 |
ユーザー |
![]() |
提出日時 | 2020-05-02 19:57:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 722 ms / 2,000 ms |
コード長 | 873 bytes |
コンパイル時間 | 385 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 123,100 KB |
最終ジャッジ日時 | 2024-12-31 09:38:19 |
合計ジャッジ時間 | 7,747 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
ソースコード
import sys from operator import itemgetter readline = sys.stdin.readline 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 = lambda x: (x[3], x[4])) 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 = -INF for j in look: res = max(res, dp[T][j]) dp[S][widx] = res + point print(max(max(d) for d in dp))