結果

問題 No.564 背の順
ユーザー sjgq5302
提出日時 2017-09-18 05:29:04
言語 Ruby
(3.4.1)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-11-08 02:17:50
合計ジャッジ時間 1,810 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

input = [] 
while line = gets     #入力のEOF(nil)に達するまで各行を読み込んでline変数に代入するwhile処理
    line.chomp!        
    input << line
end

nama = input[0].split(" ")
nama.map!(&:to_i)
input.delete_at(0)
input.map!(&:to_i)

rank = input.select{|x| x > nama[0]}.count + 1 #なま君の順位

if rank % 10 == 1 then
    puts("#{rank}st")
elsif rank % 10 == 2 then
    puts("#{rank}nd")
elsif rank % 10 == 3 then
    puts("#{rank}rd")
else
    puts("#{rank}th")
end
0