結果
問題 |
No.182 新規性の虜
|
ユーザー |
![]() |
提出日時 | 2017-08-11 09:12:30 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 55 ms / 5,000 ms |
コード長 | 833 bytes |
コンパイル時間 | 333 ms |
コンパイル使用メモリ | 20,992 KB |
実行使用メモリ | 14,344 KB |
最終ジャッジ日時 | 2024-10-09 00:11:06 |
合計ジャッジ時間 | 1,985 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
module IO = struct (* @since 4.04.0 *) let split_on_char sep s = let open String in let r = ref [] in let j = ref (length s) in for i = length s - 1 downto 0 do if get s i = sep then begin r := sub s (i + 1) (!j - i - 1) :: !r; j := i end done; sub s 0 !j :: !r let read_ss () = read_line () |> split_on_char ' ' let read_ns () = read_ss () |> List.map int_of_string end let () = read_int () |> ignore; let a = IO.read_ns () in let a = List.fast_sort (-) a in let rec doit x p acc = function | [] -> if p then acc else x :: acc | a :: tl -> if x = a then doit x true acc tl else doit a false (if p then acc else x :: acc) tl in match a with | [] -> assert false | hd :: tl -> doit hd false [] tl |> List.length |> Printf.printf "%d\n"