結果
| 問題 |
No.564 背の順
|
| コンテスト | |
| ユーザー |
r6eve
|
| 提出日時 | 2017-09-08 23:17:28 |
| 言語 | OCaml (5.2.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 498 bytes |
| コンパイル時間 | 415 ms |
| コンパイル使用メモリ | 21,384 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-09 00:28:30 |
| 合計ジャッジ時間 | 900 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
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")
r6eve