結果
| 問題 |
No.564 背の順
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-27 17:52:58 |
| 言語 | OCaml (5.2.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 833 bytes |
| コンパイル時間 | 103 ms |
| コンパイル使用メモリ | 17,152 KB |
| 最終ジャッジ日時 | 2024-11-14 20:15:16 |
| 合計ジャッジ時間 | 538 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
File "Main.ml", line 4, characters 18-29:
4 | let value = Stream.next stream in
^^^^^^^^^^^
Error: Unbound module Stream
ソースコード
let stream_filter p stream =
let rec next i =
try
let value = Stream.next stream in
if p value then Some value else next i
with Stream.Failure -> None
in
Stream.from next
let stream_length st =
let len = ref 0 in
Stream.iter (fun _ -> len := !len + 1) st;
!len
let () =
let h, n = read_line ()
|> fun l -> Scanf.sscanf l "%d %d" (fun h n -> (h, n))
in
Stream.from (fun i ->
if i >= n - 1 then None
else
let hn = read_line () |> int_of_string in
Some(hn))
|> stream_filter (fun hn -> hn > h)
|> stream_length
|> (+) 1
|> (function
| r when r mod 10 = 1 -> Printf.sprintf "%dst" r
| r when r mod 10 = 2 -> Printf.sprintf "%dnd" r
| r when r mod 10 = 3 -> Printf.sprintf "%drd" r
| r -> Printf.sprintf "%dth" r)
|> print_endline