結果

問題 No.519 アイドルユニット
ユーザー convexineqconvexineq
提出日時 2021-02-18 11:03:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 208 ms / 1,000 ms
コード長 371 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 207,720 KB
最終ジャッジ日時 2023-10-12 19:45:49
合計ジャッジ時間 5,545 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 205 ms
207,560 KB
testcase_01 AC 207 ms
207,516 KB
testcase_02 AC 122 ms
108,972 KB
testcase_03 AC 88 ms
78,492 KB
testcase_04 AC 73 ms
71,368 KB
testcase_05 AC 73 ms
71,268 KB
testcase_06 AC 71 ms
71,320 KB
testcase_07 AC 72 ms
71,216 KB
testcase_08 AC 80 ms
75,924 KB
testcase_09 AC 84 ms
76,312 KB
testcase_10 AC 87 ms
76,880 KB
testcase_11 AC 88 ms
78,368 KB
testcase_12 AC 74 ms
71,244 KB
testcase_13 AC 88 ms
78,592 KB
testcase_14 AC 88 ms
78,540 KB
testcase_15 AC 89 ms
78,304 KB
testcase_16 AC 87 ms
78,248 KB
testcase_17 AC 88 ms
78,256 KB
testcase_18 AC 88 ms
78,492 KB
testcase_19 AC 89 ms
78,420 KB
testcase_20 AC 88 ms
78,556 KB
testcase_21 AC 89 ms
78,544 KB
testcase_22 AC 86 ms
78,488 KB
testcase_23 AC 88 ms
78,604 KB
testcase_24 AC 94 ms
84,576 KB
testcase_25 AC 96 ms
84,636 KB
testcase_26 AC 94 ms
84,672 KB
testcase_27 AC 94 ms
84,564 KB
testcase_28 AC 94 ms
84,564 KB
testcase_29 AC 204 ms
207,528 KB
testcase_30 AC 208 ms
207,720 KB
testcase_31 AC 204 ms
207,648 KB
testcase_32 AC 202 ms
207,628 KB
testcase_33 AC 73 ms
71,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]
N = 1<<n
INF = 1<<30
dp = [-INF]*N
dp[0] = 0
for mask in range(N):
    if dp[mask] == -INF:continue
    v = (~mask&-(~mask)).bit_length() - 1
    for w in range(v+1,n):
        if mask>>w&1: continue
        nm = (1<<w)+(1<<v)
        dp[mask|nm] = max(dp[mask|nm], dp[mask] + d[v][w])
print(dp[-1])
0