結果

問題 No.90 品物の並び替え
ユーザー regeregeregerege
提出日時 2015-10-20 23:45:54
言語 F#
(F# 4.0)
結果
AC  
実行時間 1,837 ms / 5,000 ms
コード長 859 bytes
コンパイル時間 5,182 ms
コンパイル使用メモリ 162,748 KB
実行使用メモリ 29,520 KB
最終ジャッジ日時 2023-09-29 17:02:51
合計ジャッジ時間 9,286 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
23,356 KB
testcase_01 AC 249 ms
25,392 KB
testcase_02 AC 97 ms
23,384 KB
testcase_03 AC 113 ms
29,520 KB
testcase_04 AC 112 ms
29,496 KB
testcase_05 AC 246 ms
29,440 KB
testcase_06 AC 249 ms
27,620 KB
testcase_07 AC 100 ms
25,364 KB
testcase_08 AC 97 ms
23,392 KB
testcase_09 AC 1,837 ms
27,772 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

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