結果

問題 No.519 アイドルユニット
ユーザー tookunn_1213tookunn_1213
提出日時 2017-05-28 22:45:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 486 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 190,588 KB
最終ジャッジ日時 2023-10-21 14:27:45
合計ジャッジ時間 3,340 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
190,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 39 ms
53,332 KB
testcase_05 AC 39 ms
53,332 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 40 ms
53,332 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 45 ms
60,796 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 45 ms
60,796 KB
testcase_23 WA -
testcase_24 AC 50 ms
67,248 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 122 ms
190,364 KB
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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