結果

問題 No.1265 Balloon Survival
ユーザー 小野寺健小野寺健
提出日時 2021-11-02 11:04:40
言語 Ruby
(3.3.0)
結果
AC  
実行時間 536 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 47,232 KB
最終ジャッジ日時 2024-04-19 17:18:37
合計ジャッジ時間 9,817 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
12,160 KB
testcase_01 AC 80 ms
12,032 KB
testcase_02 AC 95 ms
12,032 KB
testcase_03 AC 84 ms
12,160 KB
testcase_04 AC 82 ms
12,160 KB
testcase_05 AC 85 ms
12,160 KB
testcase_06 AC 93 ms
12,160 KB
testcase_07 AC 84 ms
12,160 KB
testcase_08 AC 88 ms
12,160 KB
testcase_09 AC 90 ms
12,160 KB
testcase_10 AC 82 ms
12,032 KB
testcase_11 AC 82 ms
12,032 KB
testcase_12 AC 92 ms
12,160 KB
testcase_13 AC 91 ms
12,032 KB
testcase_14 AC 130 ms
15,872 KB
testcase_15 AC 124 ms
14,976 KB
testcase_16 AC 101 ms
13,056 KB
testcase_17 AC 294 ms
30,720 KB
testcase_18 AC 118 ms
13,440 KB
testcase_19 AC 108 ms
13,056 KB
testcase_20 AC 138 ms
15,744 KB
testcase_21 AC 187 ms
20,736 KB
testcase_22 AC 148 ms
17,280 KB
testcase_23 AC 158 ms
18,304 KB
testcase_24 AC 518 ms
47,232 KB
testcase_25 AC 508 ms
45,568 KB
testcase_26 AC 536 ms
45,824 KB
testcase_27 AC 503 ms
47,104 KB
testcase_28 AC 516 ms
47,104 KB
testcase_29 AC 518 ms
47,232 KB
testcase_30 AC 515 ms
45,696 KB
testcase_31 AC 497 ms
45,696 KB
testcase_32 AC 492 ms
47,232 KB
testcase_33 AC 530 ms
45,568 KB
testcase_34 AC 88 ms
12,032 KB
testcase_35 AC 82 ms
12,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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_by!{|x| x[0]}

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