結果

問題 No.564 背の順
ユーザー Lo_OTLo_OT
提出日時 2017-12-31 13:16:48
言語 Ruby
(3.3.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 568 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 11,328 KB
実行使用メモリ 15,344 KB
最終ジャッジ日時 2023-08-23 12:25:30
合計ジャッジ時間 1,872 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
15,092 KB
testcase_01 AC 83 ms
15,124 KB
testcase_02 AC 84 ms
15,056 KB
testcase_03 AC 83 ms
15,156 KB
testcase_04 AC 83 ms
15,184 KB
testcase_05 AC 83 ms
15,260 KB
testcase_06 AC 82 ms
15,168 KB
testcase_07 AC 84 ms
15,092 KB
testcase_08 AC 83 ms
15,256 KB
testcase_09 AC 83 ms
15,100 KB
testcase_10 AC 83 ms
15,344 KB
testcase_11 AC 84 ms
15,176 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

nama = gets.split.map(&:to_i)
heights = Array.new
heights.push(1000)
heights.push(nama[0])

nama[1].times do |i|
    heights[i + 1] = gets.to_i
end

heights = heights.sort.reverse

if nama[0] == 1000
    puts "1st"
    return
end

for i in 0...nama[1]
    if heights[i] > nama[0] && nama[0] > heights[i + 1]
        case i % 10
            when 0
                puts "#{i+1}st"
            when 1
                puts "#{i+1}nd"
            when 2
                puts "#{i+1}rd"
            else
                puts "#{i+1}th"
        end
        return
    end
end
0