結果

問題 No.519 アイドルユニット
ユーザー しらっ亭しらっ亭
提出日時 2017-05-29 22:24:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 1,000 ms
コード長 562 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 207,064 KB
最終ジャッジ日時 2024-04-14 06:39:28
合計ジャッジ時間 4,137 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 174 ms
206,772 KB
testcase_01 AC 179 ms
206,832 KB
testcase_02 AC 92 ms
101,640 KB
testcase_03 AC 57 ms
66,516 KB
testcase_04 AC 40 ms
53,812 KB
testcase_05 AC 39 ms
53,028 KB
testcase_06 AC 38 ms
52,724 KB
testcase_07 AC 39 ms
52,136 KB
testcase_08 AC 45 ms
59,852 KB
testcase_09 AC 53 ms
64,972 KB
testcase_10 AC 56 ms
64,928 KB
testcase_11 AC 58 ms
66,536 KB
testcase_12 AC 38 ms
52,988 KB
testcase_13 AC 56 ms
66,380 KB
testcase_14 AC 57 ms
66,060 KB
testcase_15 AC 57 ms
66,920 KB
testcase_16 AC 55 ms
66,564 KB
testcase_17 AC 57 ms
67,596 KB
testcase_18 AC 58 ms
67,292 KB
testcase_19 AC 56 ms
66,124 KB
testcase_20 AC 57 ms
67,252 KB
testcase_21 AC 56 ms
66,892 KB
testcase_22 AC 56 ms
67,236 KB
testcase_23 AC 55 ms
66,440 KB
testcase_24 AC 64 ms
74,024 KB
testcase_25 AC 62 ms
73,460 KB
testcase_26 AC 63 ms
73,812 KB
testcase_27 AC 63 ms
73,676 KB
testcase_28 AC 65 ms
74,324 KB
testcase_29 AC 176 ms
206,704 KB
testcase_30 AC 178 ms
207,048 KB
testcase_31 AC 179 ms
207,064 KB
testcase_32 AC 178 ms
206,948 KB
testcase_33 AC 38 ms
53,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n = int(input())
    A = []

    for i in range(n):
        A.append(list(map(int, input().split())))

    dp = [-1] * (1 << n)
    dp[0] = 0

    for i in range(1 << n):
        if dp[i] < 0:
            continue
        for j in range(n):
            if i & (1 << j):
                continue
            for k in range(j + 1, n):
                if i & (1 << k):
                    continue
                t = i | (1 << j) | (1 << k)
                dp[t] = max(dp[t], dp[i] + A[j][k])
            break

    return dp[-1]


print(solve())
0