結果

問題 No.1708 Quality of Contest
ユーザー 小野寺健小野寺健
提出日時 2021-10-30 17:57:21
言語 Ruby
(3.4.1)
結果
TLE  
実行時間 -
コード長 476 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 131,932 KB
最終ジャッジ日時 2024-10-07 13:48:24
合計ジャッジ時間 5,647 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 TLE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:13: warning: assigned but unused variable - k
Syntax OK

ソースコード

diff #

N, M, X = gets.split(" ").map{|s| s.to_i}

A = Hash.new {|hash, key| hash[key] = Array.new}

Max = Hash.new([-Float::INFINITY, -1])

N.times {
	a, b = gets.split(" ").map{|s| s.to_i}
	A[b] << a
	Max[b] = [a, A[b].length-1] if a > Max[b][0]
}

k = gets.to_i
c = gets.split(" ").map{|s| s.to_i}

list = []
A.each {|k, v|
	v[Max[k][1]] += X
	list += v
}

list.sort!

cnt = [0]

1.upto(c.max) {|i|
	cnt << cnt[-1] + list[N-i]
}

total = 0
c.each {|i|
	total += cnt[i]
}
puts total
0