結果
| 問題 |
No.35 タイパー高橋
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-01 00:09:28 |
| 言語 | OCaml (5.2.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 793 bytes |
| コンパイル時間 | 58 ms |
| コンパイル使用メモリ | 17,024 KB |
| 最終ジャッジ日時 | 2024-11-14 20:00:15 |
| 合計ジャッジ時間 | 417 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
File "Main.ml", line 2, characters 2-13:
2 | Stream.from (fun _ -> try Some (f (Stream.next stream))
^^^^^^^^^^^
Error: Unbound module Stream
ソースコード
let stream_map f stream =
Stream.from (fun _ -> try Some (f (Stream.next stream))
with Stream.Failure -> None)
let stream_fold f init st =
let result = ref init in
Stream.iter (fun x -> result := f !result x) st;
!result
let solve ts_st =
ts_st
|> stream_map (fun (t, s) ->
let len_s = String.length s
and len_t = t * 12 / 1000 in
let r = if len_s <= len_t then len_s else len_t in
(r, len_s - r))
|> stream_fold (fun (x1, y1) (x2, y2) -> (x1 + x2, y1 + y2)) (0, 0)
let () =
let n = read_line () |> int_of_string in
let ts_st = Stream.from (fun i ->
if i >= n then None
else read_line ()
|> fun l -> Scanf.sscanf l "%d %s" (fun t s -> Some(t, s))
) in
solve ts_st
|> fun (x, y) -> Printf.printf "%d %d\n" x y