結果

問題 No.564 背の順
ユーザー simansiman
提出日時 2020-04-08 19:16:18
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 264 bytes
コンパイル時間 411 ms
コンパイル使用メモリ 11,360 KB
実行使用メモリ 15,284 KB
最終ジャッジ日時 2023-09-26 09:43:53
合計ジャッジ時間 2,238 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,148 KB
testcase_01 AC 79 ms
15,084 KB
testcase_02 AC 80 ms
15,140 KB
testcase_03 AC 79 ms
15,148 KB
testcase_04 AC 79 ms
15,200 KB
testcase_05 AC 81 ms
15,072 KB
testcase_06 AC 80 ms
15,068 KB
testcase_07 AC 81 ms
15,176 KB
testcase_08 AC 80 ms
15,252 KB
testcase_09 AC 81 ms
15,148 KB
testcase_10 AC 81 ms
15,284 KB
testcase_11 AC 80 ms
15,172 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

H, N = gets.split.map(&:to_i)
heights = (N - 1).times.map { gets.to_i }

heights << H
heights.sort!

rank = (N - heights.rindex(H)).to_s

case rank[-1]
when '1'
  puts rank + 'st'
when '2'
  puts rank + 'nd'
when '3'
  puts rank + 'rd'
else
  puts rank + 'th'
end
0