結果

問題 No.519 アイドルユニット
ユーザー rlangevinrlangevin
提出日時 2023-11-06 20:13:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 609 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 80,360 KB
最終ジャッジ日時 2023-11-06 20:13:55
合計ジャッジ時間 4,621 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
80,360 KB
testcase_01 AC 120 ms
79,488 KB
testcase_02 AC 82 ms
76,332 KB
testcase_03 AC 62 ms
68,792 KB
testcase_04 AC 39 ms
55,740 KB
testcase_05 AC 39 ms
55,740 KB
testcase_06 AC 40 ms
55,740 KB
testcase_07 AC 39 ms
55,740 KB
testcase_08 AC 46 ms
62,188 KB
testcase_09 AC 58 ms
66,748 KB
testcase_10 AC 58 ms
68,788 KB
testcase_11 AC 63 ms
68,792 KB
testcase_12 AC 62 ms
53,692 KB
testcase_13 AC 61 ms
68,792 KB
testcase_14 AC 63 ms
68,792 KB
testcase_15 AC 62 ms
68,792 KB
testcase_16 AC 61 ms
68,792 KB
testcase_17 AC 62 ms
68,792 KB
testcase_18 AC 62 ms
68,792 KB
testcase_19 AC 63 ms
68,792 KB
testcase_20 AC 62 ms
68,792 KB
testcase_21 AC 62 ms
68,792 KB
testcase_22 AC 62 ms
68,792 KB
testcase_23 AC 63 ms
68,792 KB
testcase_24 AC 67 ms
70,816 KB
testcase_25 AC 68 ms
70,816 KB
testcase_26 AC 67 ms
70,816 KB
testcase_27 AC 67 ms
70,816 KB
testcase_28 AC 66 ms
70,816 KB
testcase_29 AC 119 ms
79,584 KB
testcase_30 AC 130 ms
79,564 KB
testcase_31 AC 130 ms
79,496 KB
testcase_32 AC 121 ms
79,528 KB
testcase_33 AC 39 ms
55,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import * 

N = int(input())
F = []
for i in range(N):
    F.append(list(map(int, input().split())))
    
pre = defaultdict(int)
pre[0] = 0
for _ in range(N//2):
    dp = defaultdict(int)
    for k, v in pre.items():
        ind = -1
        for i in range(N):
            if (k >> i) & 1 == 0:
                ind = i
                break
        else:
            break
        for i in range(ind + 1, N):
            if (k >> i) & 1 == 0:
                nk = k | (1 << ind) | (1 << i)
                dp[nk] = max(dp[nk], v + F[ind][i])
    dp, pre = pre, dp
    
print(pre[(1 << N) - 1])
0