結果

問題 No.43 野球の試合
ユーザー code-devocode-devo
提出日時 2016-04-02 13:00:43
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 539 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-10 08:17:53
合計ジャッジ時間 2,051 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
12,160 KB
testcase_01 AC 82 ms
12,032 KB
testcase_02 AC 80 ms
12,160 KB
testcase_03 AC 84 ms
12,288 KB
testcase_04 AC 84 ms
12,288 KB
testcase_05 AC 84 ms
12,160 KB
testcase_06 AC 83 ms
12,288 KB
testcase_07 AC 85 ms
12,288 KB
testcase_08 AC 79 ms
12,160 KB
testcase_09 AC 78 ms
12,288 KB
testcase_10 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n = gets.to_i
map = $stdin.read.lines.map{|s| s.chomp.chars}
map[0].each.with_index do |c,i|
  next unless c == "-"
  map[0][i] = "o"
  map[i][0] = "x"
end

loop do
  rs = map.map.with_index{|r,i| [r, i]}.select{|r,i| r.find{|c| c == "-"}}
  break if rs.size <= 0
  r, i = rs.max_by{|r,i| r.count("o")}
  j = r.map.with_index{|c,j| [c, j]}.select{|c,j| c == "-"}.max_by{|c,j| map[j].count("x")}[1]
  map[i][j] = "x"
  map[j][i] = "o"
end

win = map[0].count("o")
rank = map.map{|r| r.count("o")}.uniq.sort.reverse.index(win) + 1
puts rank
0