結果
| 問題 |
No.365 ジェンガソート
|
| コンテスト | |
| ユーザー |
k_ab_o
|
| 提出日時 | 2017-01-25 15:28:36 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 970 bytes |
| コンパイル時間 | 337 ms |
| コンパイル使用メモリ | 7,040 KB |
| 実行使用メモリ | 21,632 KB |
| 最終ジャッジ日時 | 2024-12-23 09:24:01 |
| 合計ジャッジ時間 | 7,024 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 22 |
コンパイルメッセージ
Syntax OK
ソースコード
class Xxx
attr_accessor :answer
def initialize
@answer = 0
end
def set_inputs
@n = gets.chomp.to_i
@block_lens = gets.chomp.split(" ").map{|n| n.to_i}
end
def execute
sorting = []
keeping = []
prev = nil
@block_lens.each do |n|
if prev.nil?
prev = n
keeping << n
next
end
if prev > n
sorting << n
else
keeping << n
prev = n
end
end
@answer = sorting.size
# まだ並んでないなら再度並べる
if sorting.size > 0 and keeping[0] < sorting.max
sorting2 = []
prev2 = nil
(sorting + keeping).each do |n|
if prev2.nil?
prev2 = n
next
end
if prev2 > n
sorting2 << n
else
prev2 = n
end
end
@answer += sorting2.size
end
end
end
if $0 == __FILE__
ins = Xxx.new
ins.set_inputs
ins.execute
puts ins.answer
end
k_ab_o