結果

問題 No.571 3人兄弟(その2)
ユーザー wonda_t_coffeewonda_t_coffee
提出日時 2020-02-05 09:56:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 11,860 KB
実行使用メモリ 16,048 KB
最終ジャッジ日時 2023-10-22 03:14:42
合計ジャッジ時間 2,027 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
16,048 KB
testcase_01 AC 87 ms
16,048 KB
testcase_02 AC 86 ms
16,048 KB
testcase_03 AC 86 ms
16,048 KB
testcase_04 AC 85 ms
16,048 KB
testcase_05 AC 86 ms
16,048 KB
testcase_06 AC 87 ms
16,048 KB
testcase_07 AC 87 ms
16,048 KB
testcase_08 AC 86 ms
16,048 KB
testcase_09 AC 86 ms
16,048 KB
testcase_10 AC 87 ms
16,048 KB
testcase_11 AC 86 ms
16,048 KB
testcase_12 AC 86 ms
16,048 KB
testcase_13 AC 85 ms
16,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Man
  attr_reader :name, :height, :weight
  def initialize(name:, height:, weight:)
    @name = name
    @height = height
    @weight = weight
  end
end

mans = []
('A'..'C').each do |name|
  h, w = gets.chomp.split.map(&:to_i)
  mans << Man.new(name: name, height: h, weight: w)
end

mans = mans.sort do |m1, m2|
  if m1.height > m2.height
    0
  elsif m1.height < m2.height
    1
  else
    m1.weight < m2.weight ? 0 : 1
  end
end

mans.each do |m|
  puts m.name
end
0