結果

問題 No.467 隠されていたゲーム
ユーザー suppy193suppy193
提出日時 2017-01-11 11:38:28
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 806 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,592 KB
実行使用メモリ 15,896 KB
最終ジャッジ日時 2023-08-23 06:58:37
合計ジャッジ時間 5,918 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,352 KB
testcase_01 AC 80 ms
15,360 KB
testcase_02 AC 80 ms
15,052 KB
testcase_03 AC 79 ms
15,300 KB
testcase_04 AC 79 ms
15,308 KB
testcase_05 AC 78 ms
15,180 KB
testcase_06 AC 78 ms
15,156 KB
testcase_07 AC 78 ms
15,080 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Main.rb:6: warning: assigned but unused variable - x
Main.rb:6: warning: assigned but unused variable - y
Syntax OK

ソースコード

diff #

n = gets.to_i
@cheby = gets.strip.split(' ').map(&:to_i)
#p @cheby
@goal = gets.strip.split(' ').map(&:to_i)
#p @goal
x, y = 0, 0


points_x = [0]
count_x = 0
100.times do
	next_points_x = []
	count_x += 1
	points_x.each do |point_x|
		@cheby.each do |d|
			next_points_x << point_x - d
			next_points_x << point_x + d
		end
	end
	if next_points_x.include?(@goal[0])
		#p count_x
		break
	end
	#p next_points
	points_x = next_points_x.uniq
end
#p points_x

points_y = [0]
count_y = 0
100.times do
	next_points_y = []
	count_y += 1
	points_y.each do |point_y|
		@cheby.each do |d|
			next_points_y << point_y - d
			next_points_y << point_y + d
		end
	end
	if next_points_y.include?(@goal[1])
		#p count_y
		break
	end
	#p next_points
	points_y = next_points_y.uniq
end
#p points_y
p [count_x, count_y].max
0