結果
問題 | No.90 品物の並び替え |
ユーザー | natoriusan |
提出日時 | 2023-07-30 12:36:15 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 3,800 ms / 5,000 ms |
コード長 | 930 bytes |
コンパイル時間 | 8,927 ms |
コンパイル使用メモリ | 200,168 KB |
実行使用メモリ | 96,336 KB |
最終ジャッジ日時 | 2024-04-17 13:52:33 |
合計ジャッジ時間 | 19,005 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 344 ms
34,968 KB |
testcase_01 | AC | 1,044 ms
64,384 KB |
testcase_02 | AC | 341 ms
35,128 KB |
testcase_03 | AC | 388 ms
45,272 KB |
testcase_04 | AC | 420 ms
51,176 KB |
testcase_05 | AC | 1,138 ms
64,116 KB |
testcase_06 | AC | 899 ms
64,028 KB |
testcase_07 | AC | 351 ms
37,312 KB |
testcase_08 | AC | 342 ms
35,304 KB |
testcase_09 | AC | 3,800 ms
96,336 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (228 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) /home/judge/data/code/Main.fs(1,5): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj] /home/judge/data/code/Main.fs(22,13): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj] main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
let [|n; m|] = stdin.ReadLine().Split " " |> Array.map int let arr = [| for _ in 0..m-1 -> stdin.ReadLine().Split " " |> Array.map int |] let rec permutation: (int array * int array -> int array array) = function | arr, [||] -> [|arr|] | arr, choice -> [| for i in 0..choice.Length-1 -> let a = Array.append arr [|choice.[i]|] if i = 0 then permutation (a, choice.[i+1..]) else permutation (a, (Array.append choice.[..i-1] choice.[i+1..])) |] |> Array.concat let calcScore a = [| for [|i; j; score|] in arr -> if Array.findIndex ((=)i) a < (Array.findIndex ((=)j) a) then score else 0 |] |> Array.sum permutation ([||], [|0..n-1|]) |> Array.map calcScore |> Array.max |> printfn "%d"