結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー suppy193
提出日時 2017-02-10 10:34:14
言語 Ruby
(3.4.1)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 50 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2024-12-26 14:23:29
合計ジャッジ時間 5,799 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.strip.to_i
level = gets.strip.split(' ').map(&:to_i)
t = gets.strip.to_i
memo = Hash.new()
ac = Hash.new(0)
scores = Hash.new(0)
ranking = Hash.new([])
t.times do
	name, problem = gets.strip.split(' ')
	ac[problem] += 1

	score = (50 * level[problem[0].ord - 'A'.ord] + 50 * level[problem[0].ord - 'A'.ord] / (0.8 + 0.2 * ac[problem])).floor
	# p score
	ranking[scores[name]].delete(name)
	scores[name] += score
	ranking[scores[name]] += [name]
	unless memo.key?(name)
		memo[name] = Hash.new(0)
	end
	memo[name][problem] = score
end
ranking = ranking.sort{|a, b| b[0] <=> a[0]}

i = 1
ranking.each do |arr|
	arr[1].each do |name|
		print "#{i} #{name} " 
		(0...n).each do |j|
			if memo[name].key?(('A'.ord + j).chr)
				print "#{memo[name][('A'.ord + j).chr]} "
			else
				print "0 "
			end
			
		end
		print "#{scores[name]}\n"
		i += 1
	end	
end
0