結果

問題 No.156 キャンディー・ボックス
ユーザー xsd
提出日時 2020-06-14 23:53:00
言語 OCaml
(5.2.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 311 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 21,708 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 01:13:46
合計ジャッジ時間 1,309 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

Scanf.scanf "%d %d" (fun n m ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun c -> c)) in
    Array.sort compare a;
    let rec loop i sum =
        if m - sum > a.(i) then loop (i + 1) (sum + a.(i)) else
            if m - sum = a.(i) then i + 1 else i
    in
    loop 0 0 |> Printf.printf "%d\n"
)
0