提出 #345995


ソースコード 拡げる

let pf = Printf.printf ;;
let epf = Printf.eprintf ;;
let sf = Scanf.scanf ;;

let (|>) x f = f x ;;
let (@@) f x = f x ;;

module Array = struct
  include ArrayLabels
  let foldi ~f ~init arr =
    let acc = ref init in
    for i = 0 to Array.length arr - 1 do
      acc := f i !acc arr.(i)
    done;
    !acc
  ;;

  let findi arr ~f =
    let len = Array.length arr in
    let rec iter i =
      if i = len then None
      else if f arr.(i) then Some i
      else iter (i + 1) in
    iter 0
  ;;

  let findi_exn arr ~f =
    let len = Array.length arr in
    let rec iter i =
      if i = len then None
      else if f arr.(i) then Some i
      else iter (i + 1) in
    iter 0
  ;;

  (* i ∈ [0..res) -> not (f i) /\ i ∈ [res, len) -> f i *)
  let lower_bound arr ~f =
    let l, h = 0, Array.length arr in
    (* res ∈ (l, h] *)
    let rec iter l h =
      if l = h - 1 then h
      else 
        let m = (l + h) lsr 1 in
        if f m then iter l m
        else iter m h in
    iter l h
  ;;

  (* i ∈ [0..res] -> f i /\ i ∈ (res, len) -> not (f i) *)
  let upper_bound arr ~f =
    let l, h = 0, Array.length arr in
    (* res ∈ [l, h) *)
    let rec iter l h =
      if l = h - 1 then l
      else 
        let m = (l + h) lsr 1 in
        if f m then iter m h
        else iter l m in
    iter l h
  ;;
end
  
module String = StringLabels ;;
module List  = struct
  include ListLabels ;;
  let rec repeat n a = if n = 0 then [] else a :: repeat (n - 1) a ;;
  let rec drop n a =
    if n = 0 then a
    else match a with
    | [] -> failwith "cannot take"
    | x :: xs -> drop (n - 1) xs ;;

  let init ~f n =
    let res = ref [] in
    for i = 0 to n - 1 do
      res := f i :: !res
    done;
    List.rev !res
  ;;
end ;;
module H = Hashtbl ;;

let c = ref ' ' ;;
let is_num c = '0' <= c && c <= '9' ;;
let is_space c = c = ' ' || c = '\n' || c = '\t' ;;
let to_num c = Char.code c - Char.code '0' ;;
let read_char () = input_char stdin ;;

let next_int () =
  while is_space !c do
    c := read_char () ;
  done;
  let ok = ref false in
  let acc = ref 0 in
  while is_num !c do
    ok := true;
    acc := !acc * 10 + to_num !c;
    c := read_char ();
  done;
  if !ok then !acc
  else raise (Failure "next_int")
;; 

module SI = Set.Make (struct
  type t = int 
  let compare = compare
end)

let () =
  sf "%d %d %d " (fun a b c ->
    pf "%d\n" @@ List.nth (List.sort ~cmp:compare [a; b; c]) 1)
;;

提出情報

提出日時
問題 A - 高橋くんと年齢
ユーザ iab
言語 OCaml (3.12.1)
得点 100
コード長 2540 Byte
結果 AC
実行時間 24 ms
メモリ 932 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 100 / 100
結果
AC × 4
AC × 24
セット名 テストケース
Sample subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt
All 0.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt
ケース名 結果 実行時間 メモリ
0.txt AC 22 ms 932 KiB
1.txt AC 22 ms 928 KiB
10.txt AC 23 ms 916 KiB
11.txt AC 22 ms 800 KiB
12.txt AC 21 ms 800 KiB
13.txt AC 22 ms 812 KiB
14.txt AC 24 ms 796 KiB
15.txt AC 21 ms 928 KiB
16.txt AC 23 ms 796 KiB
17.txt AC 23 ms 928 KiB
18.txt AC 23 ms 808 KiB
19.txt AC 23 ms 924 KiB
2.txt AC 24 ms 808 KiB
3.txt AC 23 ms 928 KiB
4.txt AC 22 ms 920 KiB
5.txt AC 23 ms 796 KiB
6.txt AC 22 ms 924 KiB
7.txt AC 21 ms 928 KiB
8.txt AC 21 ms 800 KiB
9.txt AC 23 ms 928 KiB
subtask0_sample_01.txt AC 23 ms 928 KiB
subtask0_sample_02.txt AC 23 ms 848 KiB
subtask0_sample_03.txt AC 23 ms 932 KiB
subtask0_sample_04.txt AC 22 ms 736 KiB