結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-21 14:45:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 418 ms / 5,000 ms |
| コード長 | 475 bytes |
| コンパイル時間 | 592 ms |
| コンパイル使用メモリ | 82,324 KB |
| 実行使用メモリ | 76,704 KB |
| 最終ジャッジ日時 | 2025-04-21 14:45:24 |
| 合計ジャッジ時間 | 2,163 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
from collections import defaultdict
N, M = map(int, input().split())
points = defaultdict(list)
for _ in range(M):
a, b, c = map(int, input().split())
points[a].append((b, c))
ans = 0
def dfs(arr, score):
if len(arr) == N:
global ans
ans = max(ans, score)
return
for j in range(N):
if j in arr:
continue
val = 0
for b, c in points[j]:
if b not in arr:
val += c
dfs(arr + [j], score + val)
dfs([], 0)
print(ans)