結果

問題 No.90 品物の並び替え
ユーザー tookunn_1213tookunn_1213
提出日時 2016-06-28 22:39:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 791 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 17,820 KB
最終ジャッジ日時 2024-04-20 03:05:49
合計ジャッジ時間 9,246 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,752 KB
testcase_01 AC 734 ms
10,752 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 103 ms
10,752 KB
testcase_04 AC 103 ms
10,752 KB
testcase_05 AC 736 ms
10,752 KB
testcase_06 AC 720 ms
10,752 KB
testcase_07 AC 38 ms
10,752 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

class Main:
	N,M = 0,0
	score = [[]]
	used = []
	def __init__(self):
		pass

	def dfs(self,n,s):
		if n == self.N:
			lis = list(str(s))
			ret = 0
			for i in range(self.N):
				for j in range(i + 1,self.N):
					ret += self.score[int(lis[i])][int(lis[j])]
			return ret
		ret = 0
		for i in range(1,self.N + 1):
			if self.used[i]:
				continue
			self.used[i] = True
			ret = max(ret,self.dfs(n + 1,s * 10 + i))
			self.used[i] = False
		return ret
	def run(self):
		self.N,self.M = map(int,input().split())
		self.used = [False for i in range(self.N + 1)]
		self.score = [[0 for j in range(self.N + 1)]for i in range(self.N + 1)]
		for i in range(self.M):
			f,s,t = map(int,input().split())
			self.score[f + 1][s + 1] = t
		print(self.dfs(0,0))
if __name__ == '__main__':
	Main().run()
0