結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー neko_the_shadowneko_the_shadow
提出日時 2016-11-20 20:43:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 949 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 11,220 KB
実行使用メモリ 17,732 KB
最終ジャッジ日時 2023-08-27 02:39:53
合計ジャッジ時間 4,745 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,304 KB
testcase_01 AC 83 ms
15,140 KB
testcase_02 AC 83 ms
15,256 KB
testcase_03 AC 91 ms
15,440 KB
testcase_04 AC 92 ms
15,432 KB
testcase_05 AC 120 ms
16,468 KB
testcase_06 AC 136 ms
16,732 KB
testcase_07 AC 107 ms
15,816 KB
testcase_08 AC 113 ms
15,920 KB
testcase_09 AC 134 ms
16,876 KB
testcase_10 AC 90 ms
15,360 KB
testcase_11 AC 93 ms
15,504 KB
testcase_12 AC 99 ms
15,808 KB
testcase_13 AC 127 ms
16,248 KB
testcase_14 AC 136 ms
16,588 KB
testcase_15 AC 94 ms
15,684 KB
testcase_16 AC 94 ms
15,292 KB
testcase_17 AC 92 ms
15,696 KB
testcase_18 AC 87 ms
15,008 KB
testcase_19 AC 144 ms
17,732 KB
testcase_20 AC 141 ms
16,728 KB
testcase_21 AC 96 ms
15,460 KB
testcase_22 AC 94 ms
15,324 KB
testcase_23 AC 101 ms
15,796 KB
testcase_24 AC 124 ms
16,588 KB
testcase_25 AC 137 ms
17,052 KB
testcase_26 AC 110 ms
15,992 KB
testcase_27 AC 106 ms
15,980 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Main.rb:3: warning: assigned but unused variable - t
Syntax OK

ソースコード

diff #

n = gets.to_i
star_table = gets.split.map(&:to_i)
t = gets.to_i
lines = ARGF.map do |line|
  name, question = line.split
  [name, question.ord - "A".ord]
end


ranking_table = Hash.new(0)
score_table = Hash.new{|ht, ky| ht[ky] = Array.new(star_table.size, 0)}
last_table = Hash.new(Float::INFINITY)

lines.each.with_index(0) do |(name, question), idx|
  star = star_table[question]
  ranking = (ranking_table[question] += 1)
  
  score_table[name][question] = (star * 50 + 50 * star / (0.8 + 0.2 * ranking)).to_i  
  last_table[name] = idx
end

names = score_table.keys.sort do |name1, name2| 
  diff = score_table[name2].reduce(:+) - score_table[name1].reduce(:+)
  diff.zero? ? last_table[name1] - last_table[name2] : diff 
end

results = []
names.each.with_index(1) do |name, idx|
  scores = score_table[name].map(&:to_s).join("\s")
  sum = score_table[name].reduce(:+)
  results << "#{idx} #{name} #{scores} #{sum}"
end

puts results.join("\n")
0