結果
| 問題 |
No.447 ゆきこーだーの雨と雪 (2)
|
| ユーザー |
siman
|
| 提出日時 | 2023-01-02 09:50:05 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 140 ms / 2,000 ms |
| コード長 | 876 bytes |
| コンパイル時間 | 45 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 14,592 KB |
| 最終ジャッジ日時 | 2024-11-27 00:38:30 |
| 合計ジャッジ時間 | 3,845 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
コンパイルメッセージ
Syntax OK
ソースコード
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.0001 * penalty[row.first] }.reverse_each.with_index(1) do |row, rank|
puts "#{rank} #{row.join(' ')}"
end
siman