結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2015-10-20 23:45:54 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 2,760 ms / 5,000 ms |
コード長 | 859 bytes |
コンパイル時間 | 14,369 ms |
コンパイル使用メモリ | 186,980 KB |
実行使用メモリ | 59,576 KB |
最終ジャッジ日時 | 2024-07-22 11:07:29 |
合計ジャッジ時間 | 22,583 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (448 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
let ``No.90 品物の並び替え`` () = let rec insertions x = function | [] -> [[x]] | (y :: ys) as l -> (x::l)::(List.map (fun x -> y::x) (insertions x ys)) let rec permutations = function | [] -> seq [ [] ] | x :: xs -> Seq.concat (Seq.map (insertions x) (permutations xs)) let arr = stdin.ReadLine().Split(' ') let N = int arr.[0] let M = int arr.[1] let score = List.init N (fun _ -> Array.init N (fun _ -> 0)) seq { for i in 1..M -> Array.map int (stdin.ReadLine().Split(' ')) } |> Seq.take M |> Seq.iter (fun a -> score.[a.[0]].[a.[1]] <- a.[2]) permutations [0..(N-1)] |> Seq.map (fun m -> Seq.sum <| seq { for a in 0..(N-1) do for b in (a+1)..(N-1) -> score.[m.[a]].[m.[b]] }) |> Seq.max |> (printfn "%d") ``No.90 品物の並び替え`` ()