結果
問題 | No.90 品物の並び替え |
ユーザー |
![]() |
提出日時 | 2014-12-07 21:39:07 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 663 bytes |
コンパイル時間 | 1,322 ms |
コンパイル使用メモリ | 105,984 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 01:46:05 |
合計ジャッジ時間 | 2,208 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
import std.stdio, std.conv, std.math, std.string, std.range, std.array, std.algorithm; void main(){ auto buf = readln().strip().split().map!(to!int)(); immutable N = buf[0]; immutable M = buf[1]; int[10][10] map; foreach(immutable int i; 0 .. M) { auto buf2 = readln().strip().split().map!(to!int)(); map[buf2[0]][buf2[1]] = buf2[2]; } int[] a = iota(0, N).array(); int ans; do { int t; foreach(immutable int i; 0 .. N) { foreach(immutable int j; i+1 .. N) { t += map[a[i]][a[j]]; } } ans = max(ans, t); } while (nextPermutation(a)); writeln(ans); }