結果

問題 No.90 品物の並び替え
ユーザー krotonkroton
提出日時 2014-12-09 13:45:16
言語 Python2
(2.7.18)
結果
AC  
実行時間 2,320 ms / 5,000 ms
コード長 399 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 6,656 KB
実行使用メモリ 5,964 KB
最終ジャッジ日時 2023-09-02 12:08:04
合計ジャッジ時間 4,096 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,884 KB
testcase_01 AC 254 ms
5,860 KB
testcase_02 AC 11 ms
5,888 KB
testcase_03 AC 39 ms
5,932 KB
testcase_04 AC 39 ms
5,844 KB
testcase_05 AC 247 ms
5,936 KB
testcase_06 AC 248 ms
5,856 KB
testcase_07 AC 15 ms
5,932 KB
testcase_08 AC 11 ms
5,848 KB
testcase_09 AC 2,320 ms
5,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

score = [0] * 1000

N, M = map(int, raw_input().split())
for t in xrange(M):
	a, b, c = map(int, raw_input().split())
	score[a * N + b] = c
	
def solve(m):
	res = 0
	for i in xrange(0, N):
		if (m >> i) & 1 == 0:
			tmp = 0
			for j in xrange(0, N):
				if (m >> j) & 1 == 1:
					tmp += score[j * N + i]
			res = max(res, tmp + solve(m | (1 << i)))			
	return res
	
print solve(0)
0