結果

問題 No.3024 等式
ユーザー cielciel
提出日時 2017-04-22 23:29:25
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 387 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 11,328 KB
実行使用メモリ 15,392 KB
最終ジャッジ日時 2023-09-28 21:46:49
合計ジャッジ時間 10,007 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
15,244 KB
testcase_01 AC 90 ms
15,228 KB
testcase_02 AC 89 ms
14,976 KB
testcase_03 AC 89 ms
15,124 KB
testcase_04 AC 86 ms
15,016 KB
testcase_05 AC 86 ms
15,092 KB
testcase_06 AC 94 ms
15,360 KB
testcase_07 AC 95 ms
15,204 KB
testcase_08 AC 97 ms
15,224 KB
testcase_09 AC 85 ms
15,236 KB
testcase_10 AC 89 ms
15,228 KB
testcase_11 AC 93 ms
15,380 KB
testcase_12 AC 335 ms
15,352 KB
testcase_13 AC 344 ms
15,264 KB
testcase_14 AC 425 ms
15,264 KB
testcase_15 AC 92 ms
15,176 KB
testcase_16 AC 86 ms
15,224 KB
testcase_17 AC 105 ms
15,320 KB
testcase_18 AC 87 ms
15,164 KB
testcase_19 AC 92 ms
15,232 KB
testcase_20 AC 93 ms
15,392 KB
testcase_21 AC 90 ms
15,212 KB
testcase_22 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:19: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
def dfs(a,&block)
	return to_enum(:dfs,a) if !block_given?
	yield a[0] if a.size<2
	(a.size-1).times{|i|
		dfs(a[0..i]){|l|
			dfs(a[i+1..-1]){|r|
				(puts :YES;exit) if l==r
				next if l<r
				yield l+r
				yield l-r
				yield l*r
				yield Rational(l,r)
			}
		}
	}
end

n,*a=`dd`.split.map(&:to_i)
a.permutation{|b|
	next if b[0]>b[-1]
	dfs(b).each{|e|
	}
}
puts :NO
0