結果
| 問題 |
No.8042 本棚
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-24 14:15:29 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 84 ms / 2,000 ms |
| コード長 | 704 bytes |
| コンパイル時間 | 165 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-07-04 09:05:03 |
| 合計ジャッジ時間 | 3,660 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
コンパイルメッセージ
Syntax OK
ソースコード
books = gets.to_i.times.map{gets.split(" ")}
series = ["iti", "ni", "san", "yon"]
num_of_sorted_items = 0
books_last_index = books.length-1
while num_of_sorted_items < books_last_index do
(1..books_last_index-num_of_sorted_items).each do |index|
if books[index][0] < books[index-1][0] then
books[index-1], books[index] = books[index], books[index-1]
elsif books[index][0] == books[index-1][0] then
if series.index(books[index][1]) < series.index(books[index-1][1])
books[index-1], books[index] = books[index], books[index-1]
end
end
end
num_of_sorted_items += 1
end
books.each{|item| puts "#{item[0]}\s#{item[1]}"}