結果

問題 No.571 3人兄弟(その2)
ユーザー mesh1nek0x0mesh1nek0x0
提出日時 2018-11-24 12:52:58
言語 Ruby
(3.3.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 11,476 KB
実行使用メモリ 15,332 KB
最終ジャッジ日時 2023-08-26 04:51:04
合計ジャッジ時間 2,222 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
15,044 KB
testcase_01 AC 75 ms
15,180 KB
testcase_02 AC 74 ms
15,292 KB
testcase_03 AC 71 ms
15,236 KB
testcase_04 AC 73 ms
15,240 KB
testcase_05 AC 75 ms
15,240 KB
testcase_06 AC 75 ms
15,288 KB
testcase_07 AC 72 ms
15,332 KB
testcase_08 AC 72 ms
15,148 KB
testcase_09 AC 73 ms
15,320 KB
testcase_10 AC 74 ms
15,116 KB
testcase_11 AC 74 ms
15,240 KB
testcase_12 AC 77 ms
15,184 KB
testcase_13 AC 76 ms
15,196 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/bin/ruby
a = gets.chomp.split(' ')
b = gets.chomp.split(' ')
c = gets.chomp.split(' ')

height = {'A' => a[0], 'B' => b[0], 'C' => c[0]}
weight = {'A' => a[1], 'B' => b[1], 'C' => c[1]}

sorted_height = height.sort { |(k1, v1), (k2, v2)| v2.to_i <=> v1.to_i }
sorted_weight = weight.sort { |(k1, v1), (k2, v2)| v1.to_i <=> v2.to_i }

score = {'A' => 0, 'B' => 0, 'C' => 0}

## 身長でランク付け
previous = 0
lank = 30
sorted_height.each { |key, val|
  if previous > val.to_i then
    # 前回より小さいならlankを下げる
    lank -= 10
  end
  score[key] += lank
  previous = val.to_i
}

## 体重でランク付け
previous = 0
lank = 3
sorted_weight.each { |key, val|
  if previous < val.to_i then
    # 前回より体重が重いならlankを下げる
    lank -= 1
  end
  score[key] += lank
  previous = val.to_i
}
soretd_score = score.sort { |(k1, v1), (k2, v2)| v2 <=> v1 }
soretd_score.each { |(k, v)| puts k}
0