結果
問題 |
No.617 Nafmo、買い出しに行く
|
ユーザー |
|
提出日時 | 2018-09-23 04:26:24 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 605 ms / 2,000 ms |
コード長 | 1,059 bytes |
コンパイル時間 | 19,125 ms |
コンパイル使用メモリ | 195,756 KB |
実行使用メモリ | 58,620 KB |
最終ジャッジ日時 | 2024-07-20 06:35:12 |
合計ジャッジ時間 | 22,422 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (483 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 combination f lst = let rec combination' restLst curLst = match restLst with | [] -> () | e :: rest -> let curLst' = e :: curLst if f curLst' then combination' rest curLst' combination' rest curLst combination' lst [] exception RecursiveFinish let solve aLst k = let mutable result = 0 try combination (fun lst -> let sum = List.sum lst if sum = k then result <- k raise RecursiveFinish else if result < sum && sum < k then result <- sum sum < k) aLst with | RecursiveFinish -> () printfn "%d" result let () = let n, k = stdin.ReadLine() |> fun s -> s.Split() |> fun arr -> (int arr.[0], int arr.[1]) let aLst = seq { for _ in 1..n -> stdin.ReadLine() |> int } |> Seq.sort |> Seq.toList solve aLst k