結果

問題 No.519 アイドルユニット
ユーザー ああいいああいい
提出日時 2022-03-08 17:02:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 219 ms / 1,000 ms
コード長 399 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 207,744 KB
最終ジャッジ日時 2023-09-30 23:22:12
合計ジャッジ時間 5,739 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 219 ms
207,564 KB
testcase_01 AC 214 ms
207,276 KB
testcase_02 AC 121 ms
109,416 KB
testcase_03 AC 90 ms
78,236 KB
testcase_04 AC 73 ms
71,420 KB
testcase_05 AC 75 ms
71,160 KB
testcase_06 AC 74 ms
71,296 KB
testcase_07 AC 74 ms
71,504 KB
testcase_08 AC 81 ms
75,876 KB
testcase_09 AC 86 ms
76,476 KB
testcase_10 AC 88 ms
76,768 KB
testcase_11 AC 89 ms
78,240 KB
testcase_12 AC 71 ms
71,196 KB
testcase_13 AC 89 ms
78,244 KB
testcase_14 AC 89 ms
78,388 KB
testcase_15 AC 89 ms
78,696 KB
testcase_16 AC 90 ms
78,440 KB
testcase_17 AC 92 ms
78,256 KB
testcase_18 AC 89 ms
78,328 KB
testcase_19 AC 91 ms
78,596 KB
testcase_20 AC 88 ms
78,208 KB
testcase_21 AC 88 ms
78,688 KB
testcase_22 AC 89 ms
78,396 KB
testcase_23 AC 89 ms
78,296 KB
testcase_24 AC 94 ms
84,380 KB
testcase_25 AC 96 ms
84,692 KB
testcase_26 AC 96 ms
84,836 KB
testcase_27 AC 97 ms
84,836 KB
testcase_28 AC 97 ms
84,724 KB
testcase_29 AC 213 ms
207,568 KB
testcase_30 AC 212 ms
207,744 KB
testcase_31 AC 212 ms
207,252 KB
testcase_32 AC 210 ms
207,448 KB
testcase_33 AC 72 ms
71,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
F = [list(map(int,input().split())) for _ in range(n)]
dp = [-1] * (1 << n)
dp[0] = 0
for bit in range(1 << n):
    if dp[bit] < 0:continue
    i = 0
    while bit & (1 << i):i += 1
    b = bit | (1 <<i)
    for j in range(i+1,n):
        if bit >> j & 1:continue
        bj = b | (1 << j)
        if dp[bj] < dp[bit] + F[i][j]:
            dp[bj] = dp[bit] + F[i][j]
print(dp[-1])
0