結果

問題 No.564 背の順
ユーザー r6ever6eve
提出日時 2017-09-08 23:17:28
言語 OCaml
(5.1.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 19,636 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-30 07:12:57
合計ジャッジ時間 1,150 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let () =
  let h, n = Scanf.scanf "%d %d " (fun h n -> h, n) in
  let n = n - 1 in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  Array.fast_sort (fun x y -> y - x) a;
  let rec doit i =
    if i = n || h > a.(i) then i + 1
    else doit (i + 1) in
  let i = doit 0 in
  let s = string_of_int i in
  let n = String.length s in
  Printf.printf "%s%s\n" s
    (if s.[n-1] = '1' then "st"
     else if s.[n-1] = '2' then "nd"
     else if s.[n-1] = '3' then "rd"
     else "th")
0