結果
問題 |
No.365 ジェンガソート
|
ユーザー |
![]() |
提出日時 | 2017-01-25 15:23:23 |
言語 | Ruby (3.4.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 942 bytes |
コンパイル時間 | 305 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 20,096 KB |
最終ジャッジ日時 | 2024-12-23 09:23:48 |
合計ジャッジ時間 | 6,673 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 25 RE * 3 |
コンパイルメッセージ
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 keeping[0] < sorting.max sorting2 = [] prev2 = nil 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