結果

問題 No.1265 Balloon Survival
ユーザー 小野寺健小野寺健
提出日時 2021-11-02 10:29:23
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 484 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 49,664 KB
最終ジャッジ日時 2024-04-19 16:38:01
合計ジャッジ時間 11,240 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:25: warning: assigned but unused variable - d
Syntax OK

ソースコード

diff #

n = gets.to_i
xy = []
n.times {
	xy << gets.split(" ").map{|s| s.to_i}
}

dist = []

0.upto(n-1) {|i|
	xi, yi = xy[i]
	(i+1).upto(n-1) {|j|
		xj, yj = xy[j]
		d = (xi-xj)**2 + (yi-yj)**2
		dist << [d, i, j]
	}
}

dist.sort!

alive = Array.new(n, 1)
alive_n = n
remove = 0

while alive_n > 1
	d, i, j = dist.shift
	if i == 0 and alive[j] == 1 then
		remove += 1
		alive[j] = 0
		alive_n -= 1
	elsif alive[i] == 1 and alive[j] == 1 then
		alive[i] = alive[j] = 0
		alive_n -= 2
	end
end
0