結果

問題 No.90 品物の並び替え
コンテスト
ユーザー regerege
提出日時 2015-10-20 23:45:54
言語 F#
(F# 10.0 + ACL)
コンパイル:
fsharp_c _filename_
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 2,366 ms / 5,000 ms
+ 133µs
コード長 859 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 16,578 ms
コンパイル使用メモリ 220,348 KB
実行使用メモリ 67,668 KB
最終ジャッジ日時 2026-08-23 06:01:21
合計ジャッジ時間 19,657 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (387 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

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 品物の並び替え`` ()
0