-
-
Save niceonionslice/dca3141dc75232579d9feae7cb8e1184 to your computer and use it in GitHub Desktop.
C043:使用回数の調査についてテスト結果で×ででて60点、原因がわからず
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
#あなたはとあるゲームのプレイヤーです。このゲームでは課金アイテムの使用者の ID が公開されるため、 | |
#個人的な興味から課金アイテムの使用回数が一番多い人を調べようとしています。 | |
#プレイヤー ID が整数で与えられるので、一番多く出現するプレイヤー ID を出力して下さい。 | |
#一番多く出現するプレイヤー ID が複数ある場合は昇順に全て出力して下さい。 | |
#入力例 1 の場合、1 が 2 個, 2 が 2個, 3 が 1個 であり、一番多く出現する ID が | |
#1, 2 の二つであるため、"1 2" と出力してください。 | |
#入力例 2 の場合、1 が 3 個, 2 が 1個, 3 が 1個 であり、一番多く出現する ID が | |
#1 のみであるため、"1" を出力してください。 | |
# 5 | |
# 1 1 2 2 3 | |
s = gets.chomp.to_i | |
ary = gets.chomp.split(" ").take s | |
count = Hash.new(0); | |
ary.each{|elem| count[elem]+=1} | |
p count | |
puts count.select{|x, v| v == count.values.max}.keys.sort.join(" ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment