結果

問題 No.571 3人兄弟(その2)
ユーザー toshiro_yanagi
提出日時 2025-04-29 23:18:47
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 566 bytes
コンパイル時間 836 ms
コンパイル使用メモリ 8,224 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2025-04-29 23:18:50
合計ジャッジ時間 2,712 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 4 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Main
  Brother = Struct.new(:i, :h, :w)

  def start
    brothers = main
    brothers.sort_by! { |x| x.w }
    brothers.sort_by!.with_index { |x, i| x.h }
    brothers.reverse!
    echo brothers.map { |x| x.i }.join("\n")

    self.class.send(:remove_const, :Brother)
    return nil
  end 

  private

  def main
    a = []
    for i in 0...3
      h, w = input.split
      brother = Brother.new(("A".ord + i).chr, h, w)
      a += [brother]
    end
    return a
  end

  def echo(*x)
    print(*x)
    puts
  end

  def input = gets.chomp
end

Main.new.start
0