結果

問題 No.1265 Balloon Survival
ユーザー 小野寺健小野寺健
提出日時 2021-11-02 10:59:48
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 504 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 50,008 KB
最終ジャッジ日時 2024-04-19 17:12:57
合計ジャッジ時間 10,882 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
17,536 KB
testcase_01 AC 99 ms
12,160 KB
testcase_02 AC 90 ms
12,032 KB
testcase_03 AC 103 ms
12,032 KB
testcase_04 AC 100 ms
12,160 KB
testcase_05 AC 101 ms
12,160 KB
testcase_06 AC 102 ms
12,160 KB
testcase_07 AC 102 ms
12,160 KB
testcase_08 AC 91 ms
12,160 KB
testcase_09 AC 100 ms
11,904 KB
testcase_10 AC 98 ms
12,160 KB
testcase_11 AC 99 ms
12,160 KB
testcase_12 AC 88 ms
12,032 KB
testcase_13 AC 86 ms
12,160 KB
testcase_14 AC 365 ms
15,616 KB
testcase_15 AC 296 ms
14,848 KB
testcase_16 AC 154 ms
12,672 KB
testcase_17 AC 1,436 ms
28,800 KB
testcase_18 AC 189 ms
13,312 KB
testcase_19 AC 168 ms
12,928 KB
testcase_20 AC 355 ms
15,488 KB
testcase_21 AC 703 ms
20,480 KB
testcase_22 AC 451 ms
16,640 KB
testcase_23 AC 500 ms
17,280 KB
testcase_24 TLE -
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:9: warning: assigned but unused variable - max
Syntax OK

ソースコード

diff #

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

dist = []

max = 0
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, true)
alive_n = n
remove = 0

dist.each {|d, i, j|
	if i == 0 and alive[j] then
		remove += 1
		alive[j] = false
		alive_n -= 1
	elsif alive[i] and alive[j] then
		alive[i] = alive[j] = false
		alive_n -= 0
	end
	break if alive_n == 1
}

puts remove
0