結果

問題 No.1265 Balloon Survival
ユーザー 小野寺健小野寺健
提出日時 2021-11-02 10:22:47
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 460 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 51,688 KB
最終ジャッジ日時 2024-04-19 16:29:47
合計ジャッジ時間 11,396 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
19,236 KB
testcase_01 AC 78 ms
12,160 KB
testcase_02 AC 76 ms
12,288 KB
testcase_03 AC 74 ms
12,160 KB
testcase_04 AC 75 ms
12,416 KB
testcase_05 AC 76 ms
12,288 KB
testcase_06 AC 73 ms
12,160 KB
testcase_07 AC 74 ms
12,416 KB
testcase_08 AC 75 ms
12,416 KB
testcase_09 AC 76 ms
12,416 KB
testcase_10 AC 75 ms
12,416 KB
testcase_11 AC 74 ms
12,416 KB
testcase_12 AC 74 ms
12,160 KB
testcase_13 AC 74 ms
12,288 KB
testcase_14 AC 405 ms
15,872 KB
testcase_15 AC 299 ms
14,848 KB
testcase_16 AC 146 ms
13,184 KB
testcase_17 AC 1,837 ms
29,056 KB
testcase_18 AC 189 ms
13,184 KB
testcase_19 AC 150 ms
13,056 KB
testcase_20 AC 344 ms
15,744 KB
testcase_21 AC 848 ms
20,736 KB
testcase_22 AC 478 ms
16,768 KB
testcase_23 AC 572 ms
17,280 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:24: 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)
remove = 0

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

puts remove
0