結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-01 17:14:33 |
| 言語 | OCaml (5.4.1) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 496 bytes |
| 記録 | |
| コンパイル時間 | 148 ms |
| コンパイル使用メモリ | 21,056 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-25 04:18:38 |
| 合計ジャッジ時間 | 1,558 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
let solve l wlst =
let rec solve' wlst sumw result =
match wlst with
| [] -> result
| x::xs ->
if (x + sumw) > l then result
else solve' xs (sumw + x) (result + 1)
in
let wlst' = List.sort compare wlst in
solve' wlst' 0 0
let () =
let l = read_line () |> int_of_string
and _ = read_line ()
and wlst = read_line () |>
Str.split (Str.regexp_string " ") |>
List.map int_of_string
in
solve l wlst |> string_of_int |> print_endline