結果
| 問題 | No.90 品物の並び替え |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-09 21:02:21 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,018 ms / 5,000 ms |
| + 585µs | |
| コード長 | 849 bytes |
| 記録 | |
| コンパイル時間 | 1,471 ms |
| コンパイル使用メモリ | 82,248 KB |
| 実行使用メモリ | 84,104 KB |
| 最終ジャッジ日時 | 2026-10-12 01:35:10 |
| 合計ジャッジ時間 | 5,066 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 |
ソースコード
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()