Created
October 12, 2017 02:10
-
-
Save whatalnk/62caaf64181edaf8fbea8dd70e33212b to your computer and use it in GitHub Desktop.
AtCoder ARC #035 B - アットコーダー王国のコンテスト事情
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
R = 10**9 + 7 | |
n = gets.chomp.to_i | |
arr = [] | |
h = Hash.new(0) | |
n.times do | |
a = gets.chomp.to_i | |
arr << a | |
h[a] += 1 | |
end | |
arr.sort! | |
ans = 0 | |
i = n | |
arr.each do |a| | |
ans += (i * a) | |
i -= 1 | |
end | |
puts ans | |
ans = 1 | |
h.each do |key, value| | |
(1..value).each do |i| | |
ans *= i | |
ans %= R | |
end | |
end | |
puts ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment