結果

問題 No.519 アイドルユニット
ユーザー tookunn_1213tookunn_1213
提出日時 2017-05-29 22:59:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 922 ms / 1,000 ms
コード長 407 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 12,004 KB
実行使用メモリ 143,456 KB
最終ジャッジ日時 2023-10-21 17:00:16
合計ジャッジ時間 9,406 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 866 ms
141,080 KB
testcase_01 AC 922 ms
143,456 KB
testcase_02 AC 309 ms
43,852 KB
testcase_03 AC 60 ms
12,136 KB
testcase_04 AC 28 ms
10,204 KB
testcase_05 AC 30 ms
10,204 KB
testcase_06 AC 30 ms
10,204 KB
testcase_07 AC 31 ms
10,208 KB
testcase_08 AC 31 ms
10,240 KB
testcase_09 AC 32 ms
10,288 KB
testcase_10 AC 38 ms
10,552 KB
testcase_11 AC 59 ms
12,136 KB
testcase_12 AC 29 ms
10,204 KB
testcase_13 AC 58 ms
12,136 KB
testcase_14 AC 59 ms
12,136 KB
testcase_15 AC 58 ms
12,136 KB
testcase_16 AC 59 ms
12,136 KB
testcase_17 AC 59 ms
12,136 KB
testcase_18 AC 58 ms
12,136 KB
testcase_19 AC 58 ms
12,136 KB
testcase_20 AC 59 ms
12,136 KB
testcase_21 AC 59 ms
12,136 KB
testcase_22 AC 60 ms
12,136 KB
testcase_23 AC 59 ms
12,136 KB
testcase_24 AC 117 ms
18,268 KB
testcase_25 AC 119 ms
18,532 KB
testcase_26 AC 122 ms
18,532 KB
testcase_27 AC 119 ms
18,532 KB
testcase_28 AC 123 ms
18,532 KB
testcase_29 AC 878 ms
141,080 KB
testcase_30 AC 874 ms
141,080 KB
testcase_31 AC 877 ms
141,276 KB
testcase_32 AC 915 ms
143,192 KB
testcase_33 AC 29 ms
10,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
f = [[int(j) for j in input().split()] for i in range(N)]
dp = [-1] * (1 << N)
def dfs(S):
	if S == (1<<N)-1:
		return 0
	if dp[S] != -1:
		return dp[S]
	ret = 0
	index = -1
	for i in range(N):
		if (S>>i&1) == 0:
			index = i
			break
	for i in range(index+1,N):
			if S>>i&1:
				continue
			ret = max(ret,dfs(S | 1 << i | 1 << index) + f[i][index])
	dp[S] = ret
	return ret
print(dfs(0))
0