結果

問題 No.90 品物の並び替え
ユーザー tookunn_1213tookunn_1213
提出日時 2016-06-28 22:39:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 552 ms / 5,000 ms
コード長 791 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 76,856 KB
最終ジャッジ日時 2024-04-20 03:05:55
合計ジャッジ時間 2,148 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,264 KB
testcase_01 AC 130 ms
76,716 KB
testcase_02 AC 36 ms
53,760 KB
testcase_03 AC 83 ms
76,612 KB
testcase_04 AC 87 ms
76,580 KB
testcase_05 AC 130 ms
76,476 KB
testcase_06 AC 126 ms
76,856 KB
testcase_07 AC 58 ms
70,828 KB
testcase_08 AC 35 ms
52,836 KB
testcase_09 AC 552 ms
76,560 KB
権限があれば一括ダウンロードができます

ソースコード

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