結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー simansiman
提出日時 2023-01-02 09:24:30
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 11,252 KB
実行使用メモリ 18,664 KB
最終ジャッジ日時 2023-08-17 23:22:39
合計ジャッジ時間 4,621 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 77 ms
15,260 KB
testcase_02 AC 77 ms
15,092 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
L = gets.split.map(&:to_i)
T = gets.to_i

def calc_score(type, counter)
  counter[type] += 1
  (50 * L[type] + Rational(50 * L[type], 0.8 + 0.2 * counter[type])).floor
end

data = Hash.new { |h, k| h[k] = Hash.new(0) }
counter = Hash.new(0)
fast_bonus = Hash.new(0)
penalty = Hash.new(0)
scores = Hash.new(0)

T.times do |t|
  name, p_type = gets.chomp.split
  p_type = p_type.ord - 'A'.ord
  score = calc_score(p_type, counter)

  scores[name] += score
  fast_bonus[scores[name]] += 1
  penalty[name] = fast_bonus[scores[name]]
  data[name][p_type] = score
end

ranking = []
data.each do |name, d|
  row = []
  row << name
  sum = 0
  N.times do |i|
    sum += d[i]
    row << d[i]
  end
  row << sum
  ranking << row
end

ranking.sort_by { |row| row.last + 0.01 + penalty[row.first] }.each.with_index(1) do |row, rank|
  puts "#{rank} #{row.join(' ')}"
end
0