結果
問題 | No.571 3人兄弟(その2) |
ユーザー |
![]() |
提出日時 | 2018-11-24 12:52:58 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 937 bytes |
コンパイル時間 | 54 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-12-24 19:08:37 |
合計ジャッジ時間 | 2,332 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/bin/rubya = 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 = 0lank = 30sorted_height.each { |key, val|if previous > val.to_i then# 前回より小さいならlankを下げるlank -= 10endscore[key] += lankprevious = val.to_i}## 体重でランク付けprevious = 0lank = 3sorted_weight.each { |key, val|if previous < val.to_i then# 前回より体重が重いならlankを下げるlank -= 1endscore[key] += lankprevious = val.to_i}soretd_score = score.sort { |(k1, v1), (k2, v2)| v2 <=> v1 }soretd_score.each { |(k, v)| puts k}