結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
15,116 KB
testcase_01 AC 83 ms
15,068 KB
testcase_02 AC 82 ms
15,092 KB
testcase_03 AC 94 ms
15,376 KB
testcase_04 AC 92 ms
15,308 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 105 ms
15,816 KB
testcase_08 AC 107 ms
16,304 KB
testcase_09 WA -
testcase_10 AC 90 ms
15,268 KB
testcase_11 AC 97 ms
15,324 KB
testcase_12 AC 99 ms
15,624 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 97 ms
15,480 KB
testcase_16 AC 93 ms
15,680 KB
testcase_17 AC 93 ms
15,244 KB
testcase_18 AC 87 ms
15,040 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 96 ms
15,408 KB
testcase_22 AC 94 ms
15,260 KB
testcase_23 AC 101 ms
15,912 KB
testcase_24 AC 125 ms
17,312 KB
testcase_25 AC 145 ms
18,200 KB
testcase_26 AC 110 ms
16,168 KB
testcase_27 AC 108 ms
16,064 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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] + 50 * L[type] / (0.8 + 0.2 * counter[type])).to_i
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] }.reverse_each.with_index(1) do |row, rank|
  puts "#{rank} #{row.join(' ')}"
end
0