結果

問題 No.1045 直方体大学
ユーザー tamatotamato
提出日時 2020-05-01 23:38:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,076 bytes
コンパイル時間 967 ms
コンパイル使用メモリ 87,640 KB
実行使用メモリ 108,688 KB
最終ジャッジ日時 2023-08-26 16:24:00
合計ジャッジ時間 7,618 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,888 KB
testcase_01 AC 63 ms
71,756 KB
testcase_02 AC 75 ms
76,084 KB
testcase_03 AC 69 ms
76,560 KB
testcase_04 WA -
testcase_05 AC 91 ms
76,724 KB
testcase_06 AC 79 ms
76,816 KB
testcase_07 AC 82 ms
76,800 KB
testcase_08 AC 775 ms
108,420 KB
testcase_09 AC 429 ms
108,232 KB
testcase_10 AC 754 ms
108,492 KB
testcase_11 AC 759 ms
108,352 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 77 ms
76,876 KB
testcase_18 AC 219 ms
108,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9
inf = 10**9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    xyz = []
    val = set()
    for i in range(N):
        a, b, c = map(int, input().split())
        x, y, z = sorted([a, b, c])
        xyz.append((x, y, z, i))
        xyz.append((x, z, y, i))
        xyz.append((y, z, x, i))
        val.add(x)
        val.add(y)
        val.add(z)
    val.add(0)
    val = sorted(list(val))
    val2idx = {v: i for i, v in enumerate(val)}

    xyz.sort(key=lambda p: p[1])
    dp = [[-inf] * (N*3+1) for _ in range(2**N)]
    dp[0][0] = 0
    for i in range(N*3):
        x, y, z, ii = xyz[i]
        j = val2idx[x]
        for state in range(2**N):
            if state >> ii & 1:
                continue
            for last in range(j+1):
                dp[state | (1 << ii)][j] = max(dp[state | (1 << ii)][j], dp[state][last] + z)
    ans = 0
    for state in range(2**N):
        for last in range(N*3+1):
            ans = max(ans, dp[state][last])
    print(ans)


if __name__ == '__main__':
    main()
0