結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー |
|
提出日時 | 2020-06-28 20:23:38 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 258 ms / 2,000 ms |
コード長 | 445 bytes |
コンパイル時間 | 336 ms |
コンパイル使用メモリ | 22,128 KB |
実行使用メモリ | 20,352 KB |
最終ジャッジ日時 | 2024-10-09 01:42:53 |
合計ジャッジ時間 | 2,528 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
Scanf.scanf "%d %d" (fun n k ->let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) inlet module S = Set.Make (struct type t = int let compare = compare end) inlet rec loop i set =if i = n then S.max_elt set elselet set = S.fold (fun v set -> if v + a.(i) <= k then S.add (v + a.(i)) set else set) set set inloop (i + 1) setinloop 0 (S.singleton 0) |> Printf.printf "%d\n")