結果

問題 No.90 品物の並び替え
ユーザー yukicoderyukicoder
提出日時 2014-12-09 18:56:38
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 298 ms / 5,000 ms
コード長 399 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 77,320 KB
実行使用メモリ 79,340 KB
最終ジャッジ日時 2023-09-02 12:12:34
合計ジャッジ時間 2,257 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
76,464 KB
testcase_01 AC 120 ms
78,964 KB
testcase_02 AC 82 ms
76,200 KB
testcase_03 AC 99 ms
78,864 KB
testcase_04 AC 100 ms
78,920 KB
testcase_05 AC 119 ms
78,860 KB
testcase_06 AC 119 ms
79,340 KB
testcase_07 AC 91 ms
78,984 KB
testcase_08 AC 77 ms
76,224 KB
testcase_09 AC 298 ms
79,220 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