結果
問題 | No.90 品物の並び替え |
ユーザー | pajannat |
提出日時 | 2021-04-12 22:12:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 4,644 ms / 5,000 ms |
コード長 | 1,022 bytes |
コンパイル時間 | 400 ms |
コンパイル使用メモリ | 86,960 KB |
実行使用メモリ | 131,416 KB |
最終ジャッジ日時 | 2023-09-11 03:14:35 |
合計ジャッジ時間 | 7,950 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 78 ms
75,180 KB |
testcase_01 | AC | 714 ms
83,004 KB |
testcase_02 | AC | 74 ms
71,224 KB |
testcase_03 | AC | 100 ms
76,148 KB |
testcase_04 | AC | 110 ms
76,324 KB |
testcase_05 | AC | 425 ms
83,304 KB |
testcase_06 | AC | 298 ms
82,936 KB |
testcase_07 | AC | 89 ms
75,940 KB |
testcase_08 | AC | 75 ms
71,340 KB |
testcase_09 | AC | 4,644 ms
131,416 KB |
ソースコード
def main(): from sys import stdin N, M = map(int, stdin.readline().rstrip().split()) score_list = [] for i in range(M): score_list_tmp = [int(i) for i in stdin.readline().rstrip().split()] score_list.append(score_list_tmp) import itertools # 0からN-1までのリスト lis = [x for x in range(N)] # 0~N-1の品物の順列の全パターンをリストに格納。 permutations_lis = list(itertools.permutations(lis)) # 品物の順列とスコア表を比較 max_score = 0 for permutations in permutations_lis: sum = 0 # 数値列のi番目とj番目をスコア表と比較 for i in range(len(permutations)): for j in range(i+1,len(permutations)): for k in score_list: if permutations[i]==k[0] and permutations[j]==k[1]: sum += k[2] if sum > max_score: max_score = sum print(max_score) if __name__ == '__main__': main()