結果

問題 No.564 背の順
ユーザー Takuya NoguchiTakuya Noguchi
提出日時 2018-01-16 21:21:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 341 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 11,332 KB
実行使用メモリ 15,292 KB
最終ジャッジ日時 2023-08-25 19:52:47
合計ジャッジ時間 2,125 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,080 KB
testcase_01 AC 81 ms
15,120 KB
testcase_02 AC 82 ms
15,224 KB
testcase_03 AC 81 ms
15,292 KB
testcase_04 AC 82 ms
15,284 KB
testcase_05 AC 82 ms
15,060 KB
testcase_06 AC 82 ms
15,016 KB
testcase_07 AC 83 ms
15,076 KB
testcase_08 AC 83 ms
15,116 KB
testcase_09 AC 82 ms
15,104 KB
testcase_10 AC 82 ms
15,012 KB
testcase_11 AC 82 ms
15,156 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

H, _ = gets.split.map(&:to_i)

h = readlines.map(&:to_i).sort_by(&:-@)
rank = ((h.index { |_h| _h <= H } || (H > h.first ? 0 : h.length)) + 1).to_s

suffix = case rank
         when /1$/
           'st'
         when /2$/
           'nd'
         when /3$/
           'rd'
         else
           'th'
         end

puts "#{rank}#{suffix}"
0