結果

問題 No.1109 調の判定
ユーザー horiesiniti
提出日時 2023-02-10 07:49:31
言語 Ruby
(3.4.1)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 248 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-07-07 05:22:03
合計ジャッジ時間 5,315 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:17: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:3: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

require 'set'
ans=[]
n=gets.to_i
ss=Set.new(gets.split(" ").map{|e| e.to_i})
12.times{|e|
	ss2=Set[]
	[0,2,4,5,7,9,11].each{|e2|
		ss2<<(e+e2)%12
	}
	if ss.size==(ss&ss2).size then
		ans<<e
	end
} 
if ans.size==1 then
	puts ans[0]
else
	puts -1
end
0