結果
| 問題 |
No.1045 直方体大学
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2025-09-07 22:56:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 933 bytes |
| コンパイル時間 | 510 ms |
| コンパイル使用メモリ | 82,552 KB |
| 実行使用メモリ | 100,284 KB |
| 最終ジャッジ日時 | 2025-09-07 22:56:18 |
| 合計ジャッジ時間 | 5,143 ms |
|
ジャッジサーバーID (参考情報) |
judge / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 6 TLE * 1 -- * 10 |
ソースコード
from collections import defaultdict
N = int(input())
ABC = [defaultdict(int) for _ in range(N + 1)]
ans = 0
tmp = set()
for i in range(N):
abc = sorted(list(map(int,input().split())))
a,b,c = abc
ABC[1][(a,b,a,b,1<<i)] = max(ABC[1][(a,b,a,b,1<<i)], c)
ABC[1][(a,c,a,c,1<<i)] = max(ABC[1][(a,c,a,c,1<<i)], b)
ABC[1][(b,c,b,c,1<<i)] = max(ABC[1][(b,c,b,c,1<<i)], a)
ans = max(ans,max(abc))
def comb(x,y):
global ans
xy = x + y
N0 = len(ABC[x])
N1 = len(ABC[y])
for (a0,b0,c0,d0,bit0),v0 in ABC[x].items():
for (a1,b1,c1,d1,bit1),v1 in ABC[y].items():
if bit0 & bit1:
continue
if c0 >= a1 and d0 >= b1:
ABC[xy][(a0,b0,c1,d1,bit0|bit1)] = max(ABC[xy][(a0,b0,c1,d1,bit0|bit1)],v0+v1)
ans = max(ans,v0 + v1)
for i in range(2,N + 1):
a = 1 << ((i-1).bit_length() - 1)
b = i - a
comb(a,b)
print(ans)
ntuda