結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-24 14:01:40 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 5,000 ms |
| コード長 | 664 bytes |
| コンパイル時間 | 6,024 ms |
| コンパイル使用メモリ | 200,820 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-07-24 14:01:47 |
| 合計ジャッジ時間 | 6,443 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
module main;
// https://kmjp.hatenablog.jp/entry/2014/12/08/0900 より
// 順列 全探索 bitDP
import std;
void main()
{
// 入力
int N, M;
readln.chomp.formattedRead("%d %d", N, M);
auto item1 = new int[](M), item2 = new int[](M), S = new int[](M);
auto G = new int[][](N, N);
foreach (i; 0 .. M) {
readln.chomp.formattedRead("%d %d %d", item1[i], item2[i], S[i]);
G[item1[i]][item2[i]] = S[i];
}
// 答えの計算
int ans = 0;
auto V = iota(0, N).array;
do {
int tmp = 0;
foreach (x; 0 .. N) {
foreach (y; 0 .. x)
tmp += G[V[y]][V[x]];
}
ans = max(ans, tmp);
} while (V.nextPermutation);
// 答えの出力
writeln(ans);
}