結果

問題 No.564 背の順
ユーザー sjgq5302sjgq5302
提出日時 2017-09-18 05:29:04
言語 Ruby
(3.3.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 35 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-25 15:16:57
合計ジャッジ時間 1,660 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
12,288 KB
testcase_01 AC 82 ms
12,288 KB
testcase_02 AC 82 ms
12,416 KB
testcase_03 AC 83 ms
12,288 KB
testcase_04 AC 82 ms
12,160 KB
testcase_05 AC 85 ms
12,160 KB
testcase_06 AC 87 ms
12,160 KB
testcase_07 AC 80 ms
12,416 KB
testcase_08 AC 83 ms
12,416 KB
testcase_09 AC 83 ms
12,416 KB
testcase_10 AC 85 ms
12,416 KB
testcase_11 AC 85 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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