結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
12,288 KB
testcase_01 AC 80 ms
12,160 KB
testcase_02 AC 75 ms
12,160 KB
testcase_03 AC 74 ms
12,160 KB
testcase_04 AC 76 ms
12,160 KB
testcase_05 AC 76 ms
12,416 KB
testcase_06 AC 80 ms
12,160 KB
testcase_07 AC 74 ms
12,160 KB
testcase_08 AC 80 ms
12,288 KB
testcase_09 AC 78 ms
12,416 KB
testcase_10 AC 75 ms
12,416 KB
testcase_11 AC 78 ms
12,160 KB
testcase_12 AC 81 ms
12,288 KB
testcase_13 AC 80 ms
12,416 KB
testcase_14 AC 347 ms
15,872 KB
testcase_15 AC 257 ms
14,976 KB
testcase_16 AC 147 ms
12,800 KB
testcase_17 AC 1,389 ms
28,928 KB
testcase_18 AC 176 ms
13,440 KB
testcase_19 AC 144 ms
13,056 KB
testcase_20 AC 326 ms
15,744 KB
testcase_21 AC 667 ms
20,736 KB
testcase_22 AC 417 ms
16,768 KB
testcase_23 AC 462 ms
17,280 KB
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 AC 77 ms
12,160 KB
testcase_35 AC 77 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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, true)
alive_n = n
remove = 0

while alive_n > 1 do
	d, i, j = dist.shift
	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 -= 2
	end
end

puts remove
0