結果
問題 | No.241 出席番号(1) |
ユーザー |
![]() |
提出日時 | 2021-10-18 17:10:24 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 404 bytes |
コンパイル時間 | 53 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-09-19 12:28:31 |
合計ジャッジ時間 | 3,723 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
Main.rb:25: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
N = gets.to_iA = N.times.map { gets.to_i }counter = Hash.new(0)A.each do |a|counter[a] += 1endnums = [*0...N].sort_by { |i| -counter[i] }ans = Array.new(N, -1)ids = [*0...N].sort_by { |i| -A[i] }nums.each do |n|ok = falseids.each do |i|next if ans[i] != -1next if A[i] == nok = trueans[i] = nbreakendif not okputs -1exitendendputs ans