結果
問題 | No.90 品物の並び替え |
ユーザー | nanae |
提出日時 | 2017-02-09 21:01:45 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 3,767 ms / 5,000 ms |
コード長 | 849 bytes |
コンパイル時間 | 319 ms |
コンパイル使用メモリ | 10,900 KB |
実行使用メモリ | 8,700 KB |
最終ジャッジ日時 | 2023-08-26 22:41:40 |
合計ジャッジ時間 | 5,909 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 18 ms
8,680 KB |
testcase_01 | AC | 326 ms
8,584 KB |
testcase_02 | AC | 18 ms
8,652 KB |
testcase_03 | AC | 46 ms
8,700 KB |
testcase_04 | AC | 55 ms
8,660 KB |
testcase_05 | AC | 336 ms
8,596 KB |
testcase_06 | AC | 329 ms
8,656 KB |
testcase_07 | AC | 22 ms
8,564 KB |
testcase_08 | AC | 19 ms
8,624 KB |
testcase_09 | AC | 3,767 ms
8,680 KB |
ソースコード
import sys from functools import lru_cache from itertools import permutations def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def solve(): N, M = map(int, input().split()) scores = {} for i in range(M): item1, item2, score = map(int, input().split()) scores[item1, item2] = score # debug(scores, locals()) max_score = -1 for line in permutations(range(N)): # debug(line, locals()) score = 0 for i in range(N): for j in range(i + 1, N): if (line[i], line[j]) in scores: score += scores[line[i], line[j]] max_score = max(max_score, score) print(max_score) if __name__ == '__main__': solve()