結果

問題 No.182 新規性の虜
ユーザー r6ever6eve
提出日時 2017-08-11 09:12:30
言語 OCaml
(5.1.0)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 833 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 21,120 KB
実行使用メモリ 14,468 KB
最終ジャッジ日時 2024-04-17 08:39:23
合計ジャッジ時間 1,870 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 34 ms
10,564 KB
testcase_09 AC 55 ms
14,468 KB
testcase_10 AC 48 ms
12,180 KB
testcase_11 AC 39 ms
11,412 KB
testcase_12 AC 16 ms
7,508 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 44 ms
12,128 KB
testcase_19 AC 30 ms
10,144 KB
testcase_20 AC 18 ms
7,680 KB
testcase_21 AC 49 ms
12,268 KB
testcase_22 AC 22 ms
8,448 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 53 ms
14,120 KB
testcase_25 AC 47 ms
13,916 KB
testcase_26 AC 7 ms
5,504 KB
testcase_27 AC 2 ms
5,376 KB
evil01.txt AC 54 ms
15,144 KB
evil02.txt AC 55 ms
15,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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"
0