結果

問題 No.241 出席番号(1)
ユーザー simansiman
提出日時 2021-10-18 17:03:48
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 319 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 16,164 KB
最終ジャッジ日時 2023-10-19 16:13:34
合計ジャッジ時間 7,767 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 87 ms
16,108 KB
testcase_03 AC 86 ms
16,108 KB
testcase_04 AC 86 ms
16,108 KB
testcase_05 WA -
testcase_06 AC 87 ms
16,104 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 89 ms
16,108 KB
testcase_12 WA -
testcase_13 AC 86 ms
16,108 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 87 ms
16,108 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 88 ms
16,108 KB
testcase_22 AC 87 ms
16,108 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 88 ms
16,108 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:6: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

N = gets.to_i
A = N.times.map { gets.to_i }
counter = Hash.new(0)

if A.uniq.size == 1
  puts -1
  exit
end

A.each do |a|
  counter[a] += 1
end

nums = [*0...N].sort_by { |i| -counter[i] }
ans = Array.new(N, -1)

nums.each do |n|
  N.times do |i|
    next if ans[i] != -1

    ans[i] = n
    break
  end
end

puts ans
0