結果

問題 No.467 隠されていたゲーム
コンテスト
ユーザー suppy193
提出日時 2017-01-11 11:38:28
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
WA  
実行時間 -
コード長 806 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 48 ms
コンパイル使用メモリ 9,216 KB
実行使用メモリ 166,088 KB
最終ジャッジ日時 2026-05-28 00:08:34
合計ジャッジ時間 5,063 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 10 TLE * 1 -- * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:6: warning: assigned but unused variable - y
Main.rb:1: warning: assigned but unused variable - n
Main.rb:6: warning: assigned but unused variable - x
Syntax OK

ソースコード

diff #
raw source code

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