結果

問題 No.1265 Balloon Survival
ユーザー tamura2004tamura2004
提出日時 2021-01-23 18:09:16
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 787 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 11,376 KB
実行使用メモリ 53,104 KB
最終ジャッジ日時 2023-08-30 02:43:15
合計ジャッジ時間 11,299 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,376 KB
testcase_01 AC 80 ms
15,088 KB
testcase_02 AC 81 ms
15,268 KB
testcase_03 AC 83 ms
15,100 KB
testcase_04 AC 81 ms
15,084 KB
testcase_05 AC 83 ms
15,280 KB
testcase_06 AC 84 ms
15,176 KB
testcase_07 AC 81 ms
15,252 KB
testcase_08 AC 82 ms
15,332 KB
testcase_09 AC 82 ms
15,184 KB
testcase_10 AC 80 ms
15,328 KB
testcase_11 AC 81 ms
15,184 KB
testcase_12 AC 81 ms
15,104 KB
testcase_13 AC 81 ms
15,268 KB
testcase_14 AC 362 ms
18,848 KB
testcase_15 AC 285 ms
17,832 KB
testcase_16 AC 154 ms
16,012 KB
testcase_17 AC 1,510 ms
31,888 KB
testcase_18 AC 190 ms
16,644 KB
testcase_19 AC 159 ms
16,212 KB
testcase_20 AC 361 ms
19,076 KB
testcase_21 AC 739 ms
23,416 KB
testcase_22 AC 469 ms
20,384 KB
testcase_23 AC 507 ms
20,900 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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# 2点間の距離と点番号を求めて、距離の小さい順にソート
# 小さい順に取り出す
# 既に破裂した点が含まれている→何もしない
# 1番の点が含まれている->相手の点を破裂扱いにし、取り除く点に+1
# それ以外→両方の点を破裂扱いにする

n = gets.to_s.to_i
x = []
y = []
n.times do |i|
  x[i], y[i] = gets.to_s.split.map { |v| v.to_i - 1 }
end

dists = []
n.times do |i|
  n.times do |j|
    next unless i < j
    dist = (y[i] - y[j]) ** 2 + (x[i] - x[j]) ** 2
    dists << [dist, i, j]
  end
end

bang = Array.new(n) { false }
ans = 0
dists.sort.each do |d, i, j|
  next if bang[i] || bang[j]
  if i == 0
    bang[j] = true
    ans += 1
  else
    bang[i] = true
    bang[j] = true
  end
end
puts ans
0