結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー horiesiniti
提出日時 2018-03-16 16:49:23
言語 Ruby
(3.4.1)
結果
AC  
実行時間 287 ms / 5,000 ms
コード長 278 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2024-12-21 14:29:58
合計ジャッジ時間 1,649 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

gets.to_i.times{
	n=gets.to_i
	x=gets.split.map{|e| e.to_i}.sort
	hs=Hash.new(0)
	while x.size>0
		hs[x[0]]+=1
		x.shift
	end
	y=hs.values.sort
	ans=0
	while y.size>2
		y[y.size-1]-=1
		y[y.size-2]-=1
		y[y.size-3]-=1
		y=y.sort.select{|e4|
			e4>0
		}
		ans+=1
	end
	puts ans
}
0