結果

問題 No.1265 Balloon Survival
ユーザー tamura2004tamura2004
提出日時 2021-01-23 18:13:14
言語 Crystal
(1.11.2)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 18,188 ms
コンパイル使用メモリ 259,120 KB
実行使用メモリ 30,788 KB
最終ジャッジ日時 2023-09-13 13:16:19
合計ジャッジ時間 20,938 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,392 KB
testcase_01 AC 3 ms
4,508 KB
testcase_02 AC 2 ms
4,408 KB
testcase_03 AC 3 ms
4,464 KB
testcase_04 AC 3 ms
4,420 KB
testcase_05 AC 2 ms
4,464 KB
testcase_06 AC 2 ms
4,564 KB
testcase_07 AC 2 ms
4,408 KB
testcase_08 AC 2 ms
4,420 KB
testcase_09 AC 2 ms
4,392 KB
testcase_10 AC 3 ms
4,400 KB
testcase_11 AC 2 ms
4,500 KB
testcase_12 AC 3 ms
4,496 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 17 ms
8,528 KB
testcase_15 AC 13 ms
7,308 KB
testcase_16 AC 6 ms
5,472 KB
testcase_17 AC 67 ms
20,404 KB
testcase_18 AC 8 ms
5,576 KB
testcase_19 AC 7 ms
5,640 KB
testcase_20 AC 17 ms
8,396 KB
testcase_21 AC 33 ms
11,500 KB
testcase_22 AC 22 ms
11,116 KB
testcase_23 AC 25 ms
11,256 KB
testcase_24 AC 128 ms
30,636 KB
testcase_25 AC 127 ms
29,180 KB
testcase_26 AC 129 ms
30,788 KB
testcase_27 AC 126 ms
29,280 KB
testcase_28 AC 128 ms
30,572 KB
testcase_29 AC 127 ms
29,232 KB
testcase_30 AC 128 ms
29,532 KB
testcase_31 AC 128 ms
29,680 KB
testcase_32 AC 129 ms
29,464 KB
testcase_33 AC 128 ms
29,008 KB
testcase_34 AC 2 ms
4,452 KB
testcase_35 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = gets.to_s.to_i
xy = Array.new(n){ gets.to_s.split.map { |v| v.to_i64 - 1} }

dists = [] of Tuple(Int64,Int32,Int32)
n.times do |i|
  n.times do |j|
    next unless i < j
    xi,yi = xy[i]
    xj,yj = xy[j]
    dist = (yi - yj) ** 2 + (xi - xj) ** 2
    dists << {dist, i, j}
  end
end

bang = Array.new(n, false)
ans = 0_i64
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