結果

問題 No.519 アイドルユニット
ユーザー ああいいああいい
提出日時 2022-03-08 17:01:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 224 ms / 1,000 ms
コード長 397 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 207,800 KB
最終ジャッジ日時 2023-09-30 23:21:17
合計ジャッジ時間 5,848 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 217 ms
207,800 KB
testcase_01 AC 214 ms
207,560 KB
testcase_02 AC 120 ms
109,180 KB
testcase_03 AC 85 ms
78,712 KB
testcase_04 AC 69 ms
71,376 KB
testcase_05 AC 67 ms
71,216 KB
testcase_06 AC 69 ms
71,636 KB
testcase_07 AC 71 ms
71,432 KB
testcase_08 AC 74 ms
76,204 KB
testcase_09 AC 81 ms
76,456 KB
testcase_10 AC 86 ms
77,188 KB
testcase_11 AC 86 ms
78,708 KB
testcase_12 AC 69 ms
71,508 KB
testcase_13 AC 87 ms
78,640 KB
testcase_14 AC 86 ms
78,744 KB
testcase_15 AC 84 ms
78,684 KB
testcase_16 AC 85 ms
78,716 KB
testcase_17 AC 84 ms
78,692 KB
testcase_18 AC 85 ms
78,648 KB
testcase_19 AC 83 ms
78,664 KB
testcase_20 AC 85 ms
78,808 KB
testcase_21 AC 86 ms
78,456 KB
testcase_22 AC 84 ms
78,692 KB
testcase_23 AC 84 ms
78,688 KB
testcase_24 AC 90 ms
84,668 KB
testcase_25 AC 92 ms
84,976 KB
testcase_26 AC 90 ms
84,828 KB
testcase_27 AC 91 ms
84,872 KB
testcase_28 AC 90 ms
84,864 KB
testcase_29 AC 209 ms
207,552 KB
testcase_30 AC 208 ms
207,432 KB
testcase_31 AC 214 ms
207,692 KB
testcase_32 AC 224 ms
207,424 KB
testcase_33 AC 70 ms
71,376 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 >> i & 1: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